├── .SRCINFO ├── .version ├── .version_public ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── NOTICE ├── PKGBUILD ├── README.md ├── arch.install ├── arr.c ├── chandle.c ├── curl.c ├── db.c ├── debian-upstream ├── changelog ├── control ├── copyright ├── golf.manpages ├── rules ├── salsa-ci.yml ├── source │ └── format ├── upstream │ └── metadata └── watch ├── docs ├── 123-hello-world.2gg ├── CGI.2gg ├── Client-API.2gg ├── SELinux.2gg ├── SEMI.2gg ├── Server-API.2gg ├── about-golf.2gg ├── after-handler.2gg ├── application-setup.2gg ├── before-handler.2gg ├── begin-handler.2gg ├── begin-transaction.2gg ├── break-loop.2gg ├── call-extended.2gg ├── call-handler.2gg ├── call-remote.2gg ├── call-web.2gg ├── change-dir.2gg ├── change-mode.2gg ├── close-file.2gg ├── code-blocks.2gg ├── command-line.2gg ├── commit-transaction.2gg ├── concatenate-strings.2gg ├── connect-apache-tcp-socket.2gg ├── connect-apache-unix-socket.2gg ├── connect-haproxy-tcp-socket.2gg ├── connect-nginx-tcp-socket.2gg ├── connect-nginx-unix-socket.2gg ├── continue-loop.2gg ├── copy-file.2gg ├── copy-string.2gg ├── count-substring.2gg ├── current-row.2gg ├── database-config-file.2gg ├── db-error.2gg ├── debugging.2gg ├── decode-base64.2gg ├── decode-hex.2gg ├── decode-url.2gg ├── decode-web.2gg ├── decrypt-data.2gg ├── delete-cookie.2gg ├── delete-dir.2gg ├── delete-fifo.2gg ├── delete-file.2gg ├── delete-lifo.2gg ├── delete-list.2gg ├── delete-string.2gg ├── delete-tree.2gg ├── derive-key.2gg ├── directories.2gg ├── do-once.2gg ├── documentation.2gg ├── encode-base64.2gg ├── encode-hex.2gg ├── encode-url.2gg ├── encode-web.2gg ├── encrypt-data.2gg ├── error-code.2gg ├── error-handling.2gg ├── exec-program.2gg ├── exit-handler.2gg ├── extended-mode.2gg ├── file-position.2gg ├── file-storage.2gg ├── file-uploading.2gg ├── finish-output.2gg ├── flush-output.2gg ├── get-app.2gg ├── get-cookie.2gg ├── get-hash.2gg ├── get-list.2gg ├── get-message.2gg ├── get-param.2gg ├── get-req.2gg ├── get-sys.2gg ├── get-time.2gg ├── get-tree.2gg ├── gg.2gg ├── golf.2gg ├── handler-status.2gg ├── hash-string.2gg ├── hmac-string.2gg ├── if-defined.2gg ├── if-true.2gg ├── inline-code.2gg ├── install-arch-manjaro.2gg ├── install-debian.2gg ├── install-fedora-redhat-rocky-alma-centos-amazon-mageia.2gg ├── install-from-source-arch-manjaro.2gg ├── install-from-source-debian-ubuntu-raspbian.2gg ├── install-from-source-fedora-redhat-rocky-alma-centos-amazon-mageia.2gg ├── install-from-source-opensuse.2gg ├── install-in-any-folder-arch-manjaro.2gg ├── install-in-any-folder-debian-ubuntu-raspbian.2gg ├── install-in-any-folder-fedora-redhat-rocky-alma-centos-amazon-mageia.2gg ├── install-in-any-folder-opensuse.2gg ├── install-opensuse.2gg ├── install-raspbian.2gg ├── install-ubuntu.2gg ├── json-doc.2gg ├── license.2gg ├── lock-file.2gg ├── lower-string.2gg ├── mariadb-database.2gg ├── match-regex.2gg ├── memory-handling.2gg ├── mgrg.2gg ├── new-array.2gg ├── new-dir.2gg ├── new-fifo.2gg ├── new-hash.2gg ├── new-lifo.2gg ├── new-list.2gg ├── new-message.2gg ├── new-remote.2gg ├── new-tree.2gg ├── number-expressions.2gg ├── number-string.2gg ├── open-file.2gg ├── out-header.2gg ├── output-statement.2gg ├── p-num.2gg ├── p-out.2gg ├── p-path.2gg ├── p-source-file.2gg ├── p-source-line.2gg ├── p-url.2gg ├── p-web.2gg ├── pause-program.2gg ├── permissions.2gg ├── pf-out.2gg ├── pf-url.2gg ├── pf-web.2gg ├── position-list.2gg ├── postgresql-database.2gg ├── purge-array.2gg ├── purge-fifo.2gg ├── purge-hash.2gg ├── purge-lifo.2gg ├── purge-list.2gg ├── purge-tree.2gg ├── random-crypto.2gg ├── random-string.2gg ├── read-array.2gg ├── read-fifo.2gg ├── read-file.2gg ├── read-hash.2gg ├── read-json.2gg ├── read-lifo.2gg ├── read-line.2gg ├── read-list.2gg ├── read-message.2gg ├── read-remote.2gg ├── read-split.2gg ├── read-tree.2gg ├── read-xml.2gg ├── rename-file.2gg ├── replace-string.2gg ├── report-error.2gg ├── request-body.2gg ├── request.2gg ├── resize-hash.2gg ├── return-handler.2gg ├── rewind-fifo.2gg ├── rewind-lifo.2gg ├── rollback-transaction.2gg ├── run-query.2gg ├── run-remote.2gg ├── send-file.2gg ├── service.2gg ├── set-bool.2gg ├── set-cookie.2gg ├── set-number.2gg ├── set-param.2gg ├── set-string.2gg ├── silent-header.2gg ├── split-string.2gg ├── sqlite-database.2gg ├── start-loop.2gg ├── stat-file.2gg ├── statements.2gg ├── string-length.2gg ├── string-number.2gg ├── syntax-highlighting.2gg ├── temporary-file.2gg ├── text-utf.2gg ├── trace-run.2gg ├── trim-string.2gg ├── uninstall.2gg ├── uniq-file.2gg ├── unlock-file.2gg ├── unused-var.2gg ├── upper-string.2gg ├── use-cursor.2gg ├── utf-text.2gg ├── variable-scope.2gg ├── web-framework-for-C-programming-language.2gg ├── write-array.2gg ├── write-fifo.2gg ├── write-file.2gg ├── write-hash.2gg ├── write-lifo.2gg ├── write-list.2gg ├── write-message.2gg ├── write-string.2gg ├── write-tree.2gg └── xml-doc.2gg ├── gcli.c ├── gcli.h ├── gg ├── gg.te ├── golf.h ├── golf.sel ├── golf.spec ├── golf.te ├── golf.vim ├── golfmem.c ├── golfrt.c ├── golfrtc.c ├── hash.c ├── json.c ├── lite.c ├── mgrg.c ├── msg.c ├── mys.c ├── pcre2.c ├── pg.c ├── pks ├── sec.c ├── stub.c ├── stub_after.c ├── stub_before.c ├── sys ├── tree.c ├── utf.c ├── v1.c ├── vdiag ├── vmakefile └── xml.c /.SRCINFO: -------------------------------------------------------------------------------- 1 | pkgbase = golf 2 | pkgdesc = Programming language and application server for building and running web services and web applications. High performance and memory-safe. 3 | pkgver = 600.3.25 4 | pkgrel = 0 5 | url = https://golf-lang.com 6 | arch = x86_64 7 | license = Apache-2.0 8 | makedepends = make 9 | makedepends = gcc 10 | makedepends = openssl 11 | makedepends = curl 12 | makedepends = mariadb-connector-c 13 | makedepends = fcgi 14 | makedepends = postgresql-libs 15 | makedepends = sqlite3 16 | makedepends = pcre2 17 | makedepends = libxml2 18 | provides = golf 19 | source = golf-600.3.25.tar.gz::https://github.com/golf-lang/golf/archive/refs/tags/600.3.25.tar.gz 20 | md5sums = SKIP 21 | 22 | pkgname = golf 23 | -------------------------------------------------------------------------------- /.version: -------------------------------------------------------------------------------- 1 | export PACKAGE_VERSION=600.3.25 2 | -------------------------------------------------------------------------------- /.version_public: -------------------------------------------------------------------------------- 1 | export PACKAGE_VERSION=600.3.25 2 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | You can contribute to Golf by 2 | * testing of features and bug fixes, 3 | * suggesting bug fixes and enhancements both for code and documentation. You can use [Issues](https://github.com/golf-lang/golf) for most of those, or for security or private issues you can contact us via the contact form at [Golf blog](https://golf-lang.blogspot.com/) or via [email](mailto:team@golf-lang.com). 4 | * giving credit by including Golf home page link (golf-lang.com) and its logo in your web pages, 5 | * spreading the word on blogs, forums and social media, 6 | * asking questions at [Issues](https://github.com/golf-lang/golf) on how-to do things that can help you and others using Golf. 7 | 8 | Golf, like Lua, SQLite and others, is a free open source project that does not accept external code patches \- only the core team can make changes to the project. The reason for this approach comes from core team's previous experiences, with some of the factors being: 9 | * long\-term maintenance of external code patches (be it features or bugs) can be a burden, 10 | * often times more time and energy is spent to review pull requests that to do it ourselves (less overhead), 11 | * better and tighter design and quality control, 12 | * consistent vision of project direction, 13 | * licensing issues especially with code that appears to be AI generated or copied from sources that are licensed differently, 14 | * making it harder in the future to change the license without the unpopular CLAs which are lots of work for us too. There are no plans to change the license but no one can say for sure it won't happen either. For instance, recently Golf license changed from EPL to Apache, arguably a more permissive FOSS license \- that might have been difficult otherwise. 15 | * legal issues with whether the code comes from a source that may or may not have the right to contribute, 16 | * duplicate work from lack of communication, 17 | * lack of consensus and resulting frictions. 18 | 19 | Of course much can be said in support of the opposite approach for each of these points, we do get that! The decision to take this approach is not made lightly, and we believe is in the interest of keeping Golf software and the experience of user community the best possible. 20 | 21 | 22 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | GOLF 2 | Copyright 2018-2025 Gliim LLC. Official web site https://golf-lang.com/ and official blog https://golf-lang.blogspot.com/ 3 | This product includes software developed by Gliim LLC. 4 | -------------------------------------------------------------------------------- /PKGBUILD: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: Apache-2.0 2 | # Copyright 2018-2025 Gliim LLC. 3 | # Licensed under Apache License v2. See LICENSE file. 4 | # On the web http://golf-lang.com/ - this file is part of Golf framework. 5 | 6 | # Build locally: makepkg --noconfirm -s 7 | # Check this file: namcap PKGBUILD 8 | # Run installer: sudo pacman -U --noconfirm 9 | 10 | # Maintainer: Gliim LLC 11 | pkgname=golf 12 | pkgver=600.3.25 13 | pkgrel=0 14 | epoch= 15 | pkgdesc="Programming language and application server for building and running web services and web applications. High performance and memory-safe." 16 | arch=("x86_64") 17 | url="https://golf-lang.com" 18 | license=('Apache-2.0') 19 | groups=() 20 | #NOTE: when depends change, makepkg --printsrcinfo >.SRCINFO must run to refresh .SRCINFO !! 21 | depends=(make gcc openssl curl 'mariadb-libs' fcgi 'postgresql-libs' sqlite3 pcre2 libxml2 man-db) 22 | makedepends=() 23 | checkdepends=() 24 | optdepends=() 25 | provides=(golf) 26 | conflicts=() 27 | replaces=() 28 | backup=() 29 | options=() 30 | install=arch.install 31 | changelog= 32 | source=("${pkgname}-${pkgver}.tar.gz::https://github.com/golf-lang/golf/archive/refs/tags/${pkgver}.tar.gz") 33 | 34 | noextract=() 35 | md5sums=(SKIP) 36 | validpgpkeys=() 37 | 38 | prepare() { 39 | tar xvfz ${pkgname}-${pkgver}.tar.gz 40 | } 41 | 42 | build() { 43 | cd "${pkgname}-${pkgver}" 44 | make DESTDIR="$pkgdir/" clean 45 | make DESTDIR="$pkgdir/" 46 | } 47 | 48 | check() { 49 | cd "${pkgname}-${pkgver}" 50 | } 51 | 52 | package() { 53 | cd "${pkgname}-${pkgver}" 54 | make DESTDIR="$pkgdir/" install 55 | } 56 | 57 | post_install() { 58 | echo "Setting up man pages..." 59 | mandb >/dev/null 2>&1 || true 60 | } 61 | -------------------------------------------------------------------------------- /arch.install: -------------------------------------------------------------------------------- 1 | post_install() { 2 | echo "Setting up man pages..." 3 | mandb >/dev/null 2>&1 || true 4 | } 5 | post_upgrade() { 6 | post_install $1 7 | } 8 | 9 | -------------------------------------------------------------------------------- /debian-upstream/changelog: -------------------------------------------------------------------------------- 1 | golf (600.3.25-1) unstable; urgency=medium 2 | 3 | * Initial release.(Closes:1102267) 4 | 5 | -- Golf Team Sun, 20 Apr 2025 11:07:21 -0700 6 | -------------------------------------------------------------------------------- /debian-upstream/control: -------------------------------------------------------------------------------- 1 | #SPDX-License-Identifier: Apache-2.0 2 | #Copyright 2018-2025 Gliim LLC. 3 | #Licensed under Apache License v2. See LICENSE file. 4 | #On the web http://golf-lang.com/ - this file is part of Golf framework. 5 | 6 | 7 | Source: golf 8 | Section: devel 9 | Priority: optional 10 | Maintainer: Golf Team 11 | #To install build dependencies: 12 | #sudo apt update 13 | #sudo apt -y install devscripts equivs build-essential lintian 14 | #mk-build-deps -i -s sudo debian/control 15 | #Build apt with debuild -us -uc -b (.deb in parent dir afterwards) 16 | Build-Depends: libssl-dev, 17 | pkgconf, 18 | libxml2-dev, 19 | libcurl4-openssl-dev, 20 | libmariadb-dev, 21 | zlib1g-dev, 22 | libfcgi-dev, 23 | libpq-dev, 24 | libsqlite3-dev, 25 | libpcre2-dev, 26 | debhelper-compat(= 13) 27 | Standards-Version: 4.7.2 28 | Homepage: https://golf-lang.com 29 | Vcs-Browser: https://salsa.debian.org/golf/golf 30 | Vcs-Git: https://salsa.debian.org/golf/golf.git 31 | 32 | Package: golf 33 | Architecture: any 34 | #libfcgi-bin is for cgi-fcgi utility 35 | Depends: make, 36 | gcc, 37 | libssl-dev, 38 | pkgconf, 39 | libxml2-dev, 40 | libcurl4, 41 | libcurl4-openssl-dev, 42 | libmariadb-dev, 43 | zlib1g-dev, 44 | libfcgi-bin, 45 | libfcgi-dev, 46 | libpq-dev, 47 | libsqlite3-dev, 48 | libpcre2-dev, 49 | ${shlibs:Depends}, 50 | ${misc:Depends} 51 | Recommends: curl 52 | Description: Programming language for web services 53 | Programming language, tools, framework and application server for 54 | web services, web applications and command-line programs. Golf is 55 | memory safe and high performance, with code that is easy to read 56 | and write. 57 | -------------------------------------------------------------------------------- /debian-upstream/copyright: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: golf 3 | Upstream-Contact: team@golf-lang.com 4 | Source: https://github.com/golf-lang/golf 5 | 6 | Files: * 7 | Copyright: 2018-2025 Gliim LLC 8 | License: Apache-2.0 9 | 10 | Files: debian/* 11 | Copyright: 2025 Gliim LLC 12 | License: Apache-2.0 13 | 14 | License: Apache-2.0 15 | Licensed under the Apache License, Version 2.0 (the "License"); 16 | you may not use this file except in compliance with the License. 17 | You may obtain a copy of the License at 18 | . 19 | http://www.apache.org/licenses/LICENSE-2.0 20 | . 21 | Unless required by applicable law or agreed to in writing, software 22 | distributed under the License is distributed on an "AS IS" BASIS, 23 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 24 | See the License for the specific language governing permissions and 25 | limitations under the License. 26 | . 27 | On Debian systems, the complete text of the Apache License, Version 2 28 | can be found in "/usr/share/common-licenses/Apache-2.0". 29 | -------------------------------------------------------------------------------- /debian-upstream/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | #SPDX-License-Identifier: Apache-2.0 3 | #Copyright 2018-2025 Gliim LLC. 4 | 5 | %: 6 | GG_DEBIAN_BUILD=1 dh $@ 7 | 8 | -------------------------------------------------------------------------------- /debian-upstream/salsa-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | include: 3 | - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/recipes/debian.yml 4 | -------------------------------------------------------------------------------- /debian-upstream/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /debian-upstream/upstream/metadata: -------------------------------------------------------------------------------- 1 | Bug-Database: https://github.com/golf-lang/golf/issues 2 | Repository: https://github.com/golf-lang/golf.git 3 | Repository-Browse: https://github.com/golf-lang/golf 4 | Bug-Submit: https://github.com/golf-lang/golf/issues 5 | -------------------------------------------------------------------------------- /debian-upstream/watch: -------------------------------------------------------------------------------- 1 | version=4 2 | https://github.com/golf-lang/golf/tags .*/v?(\d.*)@ARCHIVE_EXT@ 3 | -------------------------------------------------------------------------------- /docs/123-hello-world.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | 123-hello-world \- Golf documentation (quick-start) 4 | .SH DESCRIPTION 5 | 6 | .LP 7 | .B STEP 1: INSTALL GOLF 8 | .LP 9 | 10 | First, \fBinstall Golf\fP. 11 | 12 | .LP 13 | .B STEP 2: BUILD IT 14 | .LP 15 | 16 | Create Hello World source file (hello.golf) in a new directory; note it's all one bash command: 17 | 18 | .RS 4 19 | .EX 20 | 21 | echo 'begin-handler /hello public 22 | @Hello World! 23 | end-handler' > hello.golf 24 | 25 | .EE 26 | .RE 27 | 28 | Create Hello World application: 29 | 30 | .RS 4 31 | .EX 32 | 33 | gg -k helloworld 34 | 35 | .EE 36 | .RE 37 | 38 | Make Hello World application: 39 | 40 | .RS 4 41 | .EX 42 | 43 | gg -q 44 | 45 | .EE 46 | .RE 47 | 48 | 49 | .LP 50 | .B STEP 3: RUN IT 51 | .LP 52 | 53 | You can run Hello World both as a service and from command line: 54 | 55 | .RS 4 56 | \[bu] 57 | As a service, first start your Hello World application server: 58 | 59 | .RS 4 60 | .EX 61 | 62 | mgrg -w 3 helloworld 63 | 64 | .EE 65 | .RE 66 | 67 | then connect to the \fBservice\fP: 68 | 69 | .RS 4 70 | .EX 71 | 72 | gg -r --req="/hello" --silent-header --service --exec 73 | 74 | .EE 75 | .RE 76 | 77 | 78 | .RE 79 | 80 | .RS 4 81 | \[bu] 82 | Execute as \fBcommand-line\fP program: 83 | 84 | .RS 4 85 | .EX 86 | 87 | gg -r --req="/hello" --silent-header --exec 88 | 89 | .EE 90 | .RE 91 | 92 | .RE 93 | 94 | 95 | .LP 96 | .B EXPECTED RESULT 97 | .LP 98 | 99 | 100 | .RS 4 101 | .EX 102 | 103 | Hello World! 104 | 105 | .EE 106 | .RE 107 | 108 | .SH SEE ALSO 109 | Quick start 110 | 111 | \fB123-hello-world\fP 112 | See all 113 | \fBdocumentation\fP 114 | -------------------------------------------------------------------------------- /docs/SEMI.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | SEMI \- Golf documentation (messages) 4 | .SH DESCRIPTION 5 | SEMI (SimplE Message Interface) is a binary format used to write (pack) and read (unpack) messages consisting of key/value pairs in the form of: 6 | 7 | .RS 4 8 | .EX 9 | 10 | =<8 byte length of value> 11 | 12 | .EE 13 | .RE 14 | 15 | can be comprised of any characters other than equal sign("=") or an exclamation point ("!"), and any surrounding whitespaces are trimmed. 16 | 17 | Value is always preceded by a 8-byte length of value (as a binary number in big-endian 64bit format), followed by the value itself, followed by the new line ("\en") at the end which is not counted in length. A special is "comment", which is always ignored, and serves the purpose of general commenting. 18 | 19 | SEMI implicitly supports binary data without the need for any kind of encoding, and the number of bytes is specified ahead of a value, making parsing efficient. 20 | .SH SEE ALSO 21 | Messages 22 | 23 | \fBget-message\fP 24 | \fBnew-message\fP 25 | \fBread-message\fP 26 | \fBSEMI\fP 27 | \fBwrite-message\fP 28 | See all 29 | \fBdocumentation\fP 30 | -------------------------------------------------------------------------------- /docs/after-handler.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | after-handler \- (service-processing) 4 | .SH PURPOSE 5 | Execute your code after a request is handled. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | after-handler 13 | \[char46].. 14 | end-after-handler 15 | 16 | .EE 17 | .RE 18 | 19 | .SH DESCRIPTION 20 | Every Golf request goes through a request dispatcher (see \fBrequest\fP()). In order to specify your code to execute after a request is handled, create source file "after-handler.golf" and implement a handler that starts with "after-handler" and ends with "end-after-handler", which will be automatically picked up and compiled with your application. 21 | 22 | If no request executes (for example if your application does not handle a given \fBrequest\fP), after-handler handler does not execute either. If you use \fBexit-handler\fP to exit current request handling, after-handler handler still executes. 23 | 24 | .SH EXAMPLES 25 | Here is a simple implementation of after-handler handler that just outputs "Hi there!!": 26 | 27 | .RS 4 28 | .EX 29 | 30 | after-handler 31 | @Hi there!! 32 | end-after-handler 33 | 34 | .EE 35 | .RE 36 | 37 | .SH SEE ALSO 38 | Service processing 39 | 40 | \fBafter-handler\fP 41 | \fBbefore-handler\fP 42 | \fBbegin-handler\fP 43 | \fBcall-handler\fP 44 | See all 45 | \fBdocumentation\fP 46 | -------------------------------------------------------------------------------- /docs/before-handler.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | before-handler \- (service-processing) 4 | .SH PURPOSE 5 | Execute your code before a request is handled. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | before-handler 13 | \[char46].. 14 | end-before-handler 15 | 16 | .EE 17 | .RE 18 | 19 | .SH DESCRIPTION 20 | Every Golf request goes through a request dispatcher (see \fBrequest\fP()), which is auto-generated. In order to specify your code to execute before a request is handled, create source file "before-handler.golf" and implement code that starts with "before-handler" and ends with "end-before-handler", which will be automatically picked up and compiled with your application. 21 | 22 | If no request executes (for example if your application does not handle a given \fBrequest\fP), before-handler handler does not execute either. 23 | 24 | .SH EXAMPLES 25 | Here is a simple implementation of before-handler handler that just outputs "Getting Started!!": 26 | 27 | .RS 4 28 | .EX 29 | 30 | before-handler 31 | @Getting Started!! 32 | end-before-handler 33 | 34 | .EE 35 | .RE 36 | 37 | .SH SEE ALSO 38 | Service processing 39 | 40 | \fBafter-handler\fP 41 | \fBbefore-handler\fP 42 | \fBbegin-handler\fP 43 | \fBcall-handler\fP 44 | See all 45 | \fBdocumentation\fP 46 | -------------------------------------------------------------------------------- /docs/break-loop.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | break-loop \- (program-flow) 4 | .SH PURPOSE 5 | Exit a loop. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | break-loop 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | break-loop will exit a loop between \fBstart-loop\fP and end-loop, \fBrun-query\fP and end-query, or \fBread-line\fP and end-read-line statements. Execution continues right after the end of the loop. 19 | 20 | .SH EXAMPLES 21 | Exit the loop after 300 loops: 22 | 23 | .RS 4 24 | .EX 25 | 26 | set-number max_loop = 300 27 | start-loop repeat 1000 use i start-with 1 28 | @Completed <> loops so far 29 | if-true i equal max_loop 30 | break-loop 31 | end-if 32 | end-loop 33 | 34 | .EE 35 | .RE 36 | 37 | .SH SEE ALSO 38 | Program flow 39 | 40 | \fBbreak-loop\fP 41 | \fBcode-blocks\fP 42 | \fBcontinue-loop\fP 43 | \fBdo-once\fP 44 | \fBexit-handler\fP 45 | \fBif-defined\fP 46 | \fBif-true\fP 47 | \fBreturn-handler\fP 48 | \fBset-bool\fP 49 | \fBstart-loop\fP 50 | See all 51 | \fBdocumentation\fP 52 | -------------------------------------------------------------------------------- /docs/change-dir.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | change-dir \- (directories) 4 | .SH PURPOSE 5 | Change current working directory. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | change-dir [ | home | run-dir ] [ status ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | change-dir will change current working directory to (which is a string that can be an absolute or relative path), or to application home directory (see \fBdirectories\fP) if "home" clause is used. 19 | 20 | If "run-dir" clause is used, then current working directory is changed to the directory where you ran the program from. Note that this only applies to \fBcommand-line\fP programs. If you program runs as a \fBservice\fP, then this clause has the same effect as "home" clause. 21 | 22 | If "status" clause is used, then number is GG_OKAY if change-dir is successful, or GG_FAILED if not (in which case you can use "errno" clause in \fBget-req\fP to find the specific reason why). 23 | 24 | Note that if you change current working directory with \fBcall-extended\fP, then you must set Golf internal boolean variable "gg_path_changed" to true. 25 | 26 | .SH EXAMPLES 27 | 28 | .RS 4 29 | .EX 30 | 31 | change-dir "/home/user/new_dir" status s 32 | if-true s equal GG_OKAY 33 | @Directory changed 34 | else 35 | get-req errno to eno 36 | @Error <> 37 | end-if 38 | 39 | .EE 40 | .RE 41 | 42 | Use relative path: 43 | 44 | .RS 4 45 | .EX 46 | 47 | change-dir "./new_dir" 48 | 49 | .EE 50 | .RE 51 | 52 | Go back to application home directory: 53 | 54 | .RS 4 55 | .EX 56 | 57 | change-dir home 58 | 59 | .EE 60 | .RE 61 | 62 | .SH SEE ALSO 63 | Directories 64 | 65 | \fBchange-dir\fP 66 | \fBchange-mode\fP 67 | \fBdelete-dir\fP 68 | \fBdirectories\fP 69 | \fBnew-dir\fP 70 | See all 71 | \fBdocumentation\fP 72 | -------------------------------------------------------------------------------- /docs/change-mode.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | change-mode \- (directories 4 | files) 5 | .SH PURPOSE 6 | Change permission mode for a file or directory. 7 | 8 | .SH SYNTAX 9 | 10 | .RS 4 11 | .EX 12 | 13 | change-mode mode [ status ] 14 | 15 | .EE 16 | .RE 17 | 18 | .SH DESCRIPTION 19 | change-mode will change permission mode for to as specified in "mode" clause. is a number, typically specified as octal (such as for instance 0750), see \fBpermissions\fP. is a string that may be an absolute or relative path. 20 | 21 | If "status" clause is used, then number is GG_OKAY if succeeded, GG_ERR_EXIST if file or directory does not exist, or GG_ERR_FAILED for other errors (in which case you can use "errno" clause in \fBget-req\fP to find the specific reason why). 22 | 23 | .SH EXAMPLES 24 | To give read and write privilege to user's group members ("6" means that as a second digit): 25 | 26 | .RS 4 27 | .EX 28 | 29 | change-mode "myfile" mode 0760 30 | 31 | .EE 32 | .RE 33 | 34 | .SH SEE ALSO 35 | Directories 36 | 37 | \fBchange-dir\fP 38 | \fBchange-mode\fP 39 | \fBdelete-dir\fP 40 | \fBdirectories\fP 41 | \fBnew-dir\fP 42 | Files 43 | 44 | \fBchange-mode\fP 45 | \fBclose-file\fP 46 | \fBcopy-file\fP 47 | \fBdelete-file\fP 48 | \fBfile-position\fP 49 | \fBfile-storage\fP 50 | \fBfile-uploading\fP 51 | \fBlock-file\fP 52 | \fBopen-file\fP 53 | \fBread-file\fP 54 | \fBread-line\fP 55 | \fBrename-file\fP 56 | \fBstat-file\fP 57 | \fBtemporary-file\fP 58 | \fBuniq-file\fP 59 | \fBunlock-file\fP 60 | \fBwrite-file\fP 61 | See all 62 | \fBdocumentation\fP 63 | -------------------------------------------------------------------------------- /docs/close-file.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | close-file \- (files) 4 | .SH PURPOSE 5 | Close file. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | close-file file-id \\ 13 | [ status ] 14 | 15 | .EE 16 | .RE 17 | 18 | .SH DESCRIPTION 19 | close-file closes file previously opened with \fBopen-file\fP, where is an open file identifier. 20 | 21 | You can obtain the status of file closing via number (in "status" clause). The is GG_OKAY if file is closed, or GG_ERR_CLOSE if could not close file. 22 | 23 | If you do not close a file opened with open-file, Golf will automatically close it when the request ends. 24 | 25 | .SH EXAMPLES 26 | See \fBopen-file\fP. 27 | .SH SEE ALSO 28 | Files 29 | 30 | \fBchange-mode\fP 31 | \fBclose-file\fP 32 | \fBcopy-file\fP 33 | \fBdelete-file\fP 34 | \fBfile-position\fP 35 | \fBfile-storage\fP 36 | \fBfile-uploading\fP 37 | \fBlock-file\fP 38 | \fBopen-file\fP 39 | \fBread-file\fP 40 | \fBread-line\fP 41 | \fBrename-file\fP 42 | \fBstat-file\fP 43 | \fBtemporary-file\fP 44 | \fBuniq-file\fP 45 | \fBunlock-file\fP 46 | \fBwrite-file\fP 47 | See all 48 | \fBdocumentation\fP 49 | -------------------------------------------------------------------------------- /docs/code-blocks.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | code-blocks \- Golf documentation (program-flow) 4 | .SH DESCRIPTION 5 | 6 | .LP 7 | .B CODE BLOCKS 8 | .LP 9 | 10 | Use curly braces ("{" and "}") to open and close a code block. They create a separate scope for previously non-existing variables defined within them, which begins with "{" and ends with "}". Note that if a variable existed in an outer scope, it cannot be created in the inner scope. 11 | 12 | Note that \fBif-true\fP, \fBrun-query\fP, \fBstart-loop\fP and \fBread-line\fP statements contain implicit code blocks, meaning the code between them and the accompanying end-statement is within implicit "{" and "}". 13 | 14 | .SH EXAMPLES 15 | The following code will first print out "outside" and then "inside" twice, illustrating the fact that variable "s1" is defined only in the outer scope once. Variable "s2" exists only in inner scope: 16 | 17 | .RS 4 18 | .EX 19 | 20 | begin-handler /scope public 21 | @<> 22 | set-string s1="outside" 23 | { 24 | set-string s2="inner variable" 25 | set-string s1="inside" 26 | @<> 27 | } 28 | @<> 29 | end-handler 30 | 31 | .EE 32 | .RE 33 | 34 | .SH SEE ALSO 35 | Program flow 36 | 37 | \fBbreak-loop\fP 38 | \fBcode-blocks\fP 39 | \fBcontinue-loop\fP 40 | \fBdo-once\fP 41 | \fBexit-handler\fP 42 | \fBif-defined\fP 43 | \fBif-true\fP 44 | \fBreturn-handler\fP 45 | \fBset-bool\fP 46 | \fBstart-loop\fP 47 | See all 48 | \fBdocumentation\fP 49 | -------------------------------------------------------------------------------- /docs/concatenate-strings.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | concatenate-strings \- (strings) 4 | .SH PURPOSE 5 | Add strings using a plus ("+") sign. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | + [ + ... ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | String variables and literals can produce a new string by concatenation, using plus ("+") clause. 19 | 20 | Concatenation in this manner can be used in any statement where a string is expected. 21 | 22 | Note that you can concatenate binary strings too, i.e. strings that do not end with a null character, with each binary string used in its true length. The result will in general be a binary string. 23 | 24 | .SH EXAMPLES 25 | For instance, here we'll concatenate two string constants and a variable "var": 26 | 27 | .RS 4 28 | .EX 29 | 30 | set-string var = "day" 31 | set-string newstr = "nice " + var + " it is!" 32 | p-out newstr new-line 33 | 34 | .EE 35 | .RE 36 | 37 | The result will be "nice day it is!". 38 | 39 | In the following case, directory (variable "dir") is concatenated with a forward slash ("/") and then file name (variable "file") to produce full path of a file to read: 40 | 41 | .RS 4 42 | .EX 43 | 44 | read-file dir+"/"+file to content 45 | 46 | .EE 47 | .RE 48 | 49 | .SH SEE ALSO 50 | Strings 51 | 52 | \fBconcatenate-strings\fP 53 | \fBcopy-string\fP 54 | \fBcount-substring\fP 55 | \fBdelete-string\fP 56 | \fBlower-string\fP 57 | \fBread-split\fP 58 | \fBreplace-string\fP 59 | \fBset-string\fP 60 | \fBsplit-string\fP 61 | \fBstring-length\fP 62 | \fBtrim-string\fP 63 | \fBupper-string\fP 64 | \fBwrite-string\fP 65 | See all 66 | \fBdocumentation\fP 67 | -------------------------------------------------------------------------------- /docs/connect-nginx-tcp-socket.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | connect-nginx-tcp-socket \- Golf documentation (web-servers) 4 | .SH DESCRIPTION 5 | This shows how to connect your application listening on TCP port (started with "-p" option in \fBmgrg\fP) to Nginx web server. 6 | 7 | 8 | .B - Step 1 9 | : 10 | You will need to edit the Nginx configuration file. For Ubuntu and similar: 11 | 12 | .RS 4 13 | .EX 14 | 15 | sudo vi /etc/nginx/sites-enabled/default 16 | 17 | .EE 18 | .RE 19 | 20 | while on Fedora and other systems it might be at: 21 | 22 | .RS 4 23 | .EX 24 | 25 | sudo vi /etc/nginx/nginx.conf 26 | 27 | .EE 28 | .RE 29 | 30 | 31 | Add the following in the "server {}" section ("/" is the application path, see \fBrequest\fP): 32 | 33 | .RS 4 34 | .EX 35 | 36 | location // { include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:; } 37 | 38 | .EE 39 | .RE 40 | 41 | 42 | .B - Step 2 43 | : 44 | Finally, restart Nginx: 45 | 46 | .RS 4 47 | .EX 48 | 49 | sudo systemctl restart nginx 50 | 51 | .EE 52 | .RE 53 | 54 | Note: you must not have any other URL resource that starts with "//" (such as for example "//something") as the web server will attempt to pass them as a reverse proxy request, and they will likely not work. If you need to, you can change the application path to be different from "/", see \fBrequest\fP. 55 | .SH SEE ALSO 56 | Web servers 57 | 58 | \fBconnect-apache-tcp-socket\fP 59 | \fBconnect-apache-unix-socket\fP 60 | \fBconnect-haproxy-tcp-socket\fP 61 | \fBconnect-nginx-tcp-socket\fP 62 | \fBconnect-nginx-unix-socket\fP 63 | See all 64 | \fBdocumentation\fP 65 | -------------------------------------------------------------------------------- /docs/connect-nginx-unix-socket.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | connect-nginx-unix-socket \- Golf documentation (web-servers) 4 | .SH DESCRIPTION 5 | This shows how to connect your application listening on a Unix socket (started with \fBmgrg\fP) to Nginx web server. 6 | 7 | 8 | .B - Step 1 9 | : 10 | You will need to edit the Nginx configuration file. For Ubuntu and similar: 11 | 12 | .RS 4 13 | .EX 14 | 15 | sudo vi /etc/nginx/sites-enabled/default 16 | 17 | .EE 18 | .RE 19 | 20 | while on Fedora and other systems it might be at: 21 | 22 | .RS 4 23 | .EX 24 | 25 | sudo vi /etc/nginx/nginx.conf 26 | 27 | .EE 28 | .RE 29 | 30 | 31 | Add the following in the "server {}" section ("/" is the application path (see \fBrequest\fP) and "" is your application name): 32 | 33 | .RS 4 34 | .EX 35 | 36 | location // { include /etc/nginx/fastcgi_params; fastcgi_pass unix:///var/lib/gg//sock/sock; } 37 | 38 | .EE 39 | .RE 40 | 41 | 42 | .B - Step 2 43 | : 44 | Finally, restart Nginx: 45 | 46 | .RS 4 47 | .EX 48 | 49 | sudo systemctl restart nginx 50 | 51 | .EE 52 | .RE 53 | 54 | Note: you must not have any other URL resource that starts with "//" (such as for example "//something") as the web server will attempt to pass them as a reverse proxy request, and they will likely not work. If you need to, you can change the application path to be different from "/", see \fBrequest\fP. 55 | .SH SEE ALSO 56 | Web servers 57 | 58 | \fBconnect-apache-tcp-socket\fP 59 | \fBconnect-apache-unix-socket\fP 60 | \fBconnect-haproxy-tcp-socket\fP 61 | \fBconnect-nginx-tcp-socket\fP 62 | \fBconnect-nginx-unix-socket\fP 63 | See all 64 | \fBdocumentation\fP 65 | -------------------------------------------------------------------------------- /docs/continue-loop.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | continue-loop \- (program-flow) 4 | .SH PURPOSE 5 | Continue to the top of a loop. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | continue-loop 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | continue-loop will continue execution at the top of the loop at \fBstart-loop\fP, \fBrun-query\fP, or \fBread-line\fP statements. 19 | 20 | .SH EXAMPLES 21 | Skip the processing if it's the loop #300: 22 | 23 | .RS 4 24 | .EX 25 | 26 | define-number cont_loop = 300 27 | start-loop repeat 1000 use i start-with 1 28 | if-true i equal cont_loop 29 | continue-loop 30 | end-if 31 | @Completed <> loops so far 32 | end-loop 33 | 34 | .EE 35 | .RE 36 | 37 | .SH SEE ALSO 38 | Program flow 39 | 40 | \fBbreak-loop\fP 41 | \fBcode-blocks\fP 42 | \fBcontinue-loop\fP 43 | \fBdo-once\fP 44 | \fBexit-handler\fP 45 | \fBif-defined\fP 46 | \fBif-true\fP 47 | \fBreturn-handler\fP 48 | \fBset-bool\fP 49 | \fBstart-loop\fP 50 | See all 51 | \fBdocumentation\fP 52 | -------------------------------------------------------------------------------- /docs/copy-file.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | copy-file \- (files) 4 | .SH PURPOSE 5 | Copies one file to another. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | copy-file to [ status ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | File is copied into , which is created if it does not exist. 19 | 20 | Status can be obtained in variable, which is GG_ERR_OPEN if cannot open source file, GG_ERR_CREATE if cannot create target file, GG_ERR_READ if cannot read source file, GG_ERR_WRITE if cannot write target file, or number of bytes copied (including 0) on success. 21 | 22 | .SH EXAMPLES 23 | 24 | .RS 4 25 | .EX 26 | 27 | copy-file "/home/user/source_file" to "/home/user/target_file" status st 28 | 29 | .EE 30 | .RE 31 | 32 | .SH SEE ALSO 33 | Files 34 | 35 | \fBchange-mode\fP 36 | \fBclose-file\fP 37 | \fBcopy-file\fP 38 | \fBdelete-file\fP 39 | \fBfile-position\fP 40 | \fBfile-storage\fP 41 | \fBfile-uploading\fP 42 | \fBlock-file\fP 43 | \fBopen-file\fP 44 | \fBread-file\fP 45 | \fBread-line\fP 46 | \fBrename-file\fP 47 | \fBstat-file\fP 48 | \fBtemporary-file\fP 49 | \fBuniq-file\fP 50 | \fBunlock-file\fP 51 | \fBwrite-file\fP 52 | See all 53 | \fBdocumentation\fP 54 | -------------------------------------------------------------------------------- /docs/copy-string.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | copy-string \- (strings) 4 | .SH PURPOSE 5 | Copies string to another string. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | copy-string to \\ 13 | [ start-with ] \\ 14 | [ length ] 15 | 16 | .EE 17 | .RE 18 | 19 | .SH DESCRIPTION 20 | Use copy-string to copy to . 21 | 22 | number (in "start-with" clause) is the position in to start copying from, with 0 being the first byte. 23 | 24 | Without "length" clause, the whole of is copied. With "length" clause, exactly bytes are copied into . 25 | 26 | You can copy a string to itself. In this case, the original string remains and the new string references a copy: 27 | 28 | .RS 4 29 | .EX 30 | 31 | set-string str = "original string" // string to change 32 | 33 | set-string orig = str // references original copy of the string to change 34 | 35 | copy-string str to str // make a copy of string to change and assign it to itself 36 | 37 | upper-string str // change the copy 38 | 39 | // Now "str" references "ORIGINAL STRING" 40 | // and "orig" references "original string" 41 | 42 | .EE 43 | .RE 44 | 45 | 46 | .SH EXAMPLES 47 | After copy-string below, "my_str" will be a copy of string "some value": 48 | 49 | .RS 4 50 | .EX 51 | 52 | set-string other_string="some value" 53 | copy-string other_string to my_str 54 | 55 | .EE 56 | .RE 57 | 58 | Copy certain number of bytes, the result in "my_str" will be "ome": 59 | 60 | .RS 4 61 | .EX 62 | 63 | set-string other_string="some value" 64 | copy-string other_string to my_str length 3 start-with 1 65 | 66 | .EE 67 | .RE 68 | 69 | .SH SEE ALSO 70 | Strings 71 | 72 | \fBconcatenate-strings\fP 73 | \fBcopy-string\fP 74 | \fBcount-substring\fP 75 | \fBdelete-string\fP 76 | \fBlower-string\fP 77 | \fBread-split\fP 78 | \fBreplace-string\fP 79 | \fBset-string\fP 80 | \fBsplit-string\fP 81 | \fBstring-length\fP 82 | \fBtrim-string\fP 83 | \fBupper-string\fP 84 | \fBwrite-string\fP 85 | See all 86 | \fBdocumentation\fP 87 | -------------------------------------------------------------------------------- /docs/count-substring.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | count-substring \- (strings) 4 | .SH PURPOSE 5 | Count substrings. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | count-substring in to [ case-insensitive [ ] ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | count-substring counts the number of occurrences of in and stores the result in (specified in "to" clause). By default, search is case-sensitive. If you use "case-insensitive" clause without boolean variable , or if evaluates to true, then the search is case-insensitive. 19 | 20 | If is empty (""), is 0. 21 | 22 | .SH EXAMPLES 23 | In the following example, 1 occurrence will be found after the first count-substring, and 2 after the second (since case insensitive search is used there): 24 | 25 | .RS 4 26 | .EX 27 | 28 | set-string sub = "world" 29 | set-string str = "Hello world and hello World!" 30 | 31 | count-substring sub in str to num_occ 32 | pf-out "Found %ld occurrences!\en", num_occ 33 | 34 | count-substring sub in str to num_occ case-insensitive 35 | pf-out "Found %ld occurrences!\en", num_occ 36 | 37 | .EE 38 | .RE 39 | 40 | .SH SEE ALSO 41 | Strings 42 | 43 | \fBconcatenate-strings\fP 44 | \fBcopy-string\fP 45 | \fBcount-substring\fP 46 | \fBdelete-string\fP 47 | \fBlower-string\fP 48 | \fBread-split\fP 49 | \fBreplace-string\fP 50 | \fBset-string\fP 51 | \fBsplit-string\fP 52 | \fBstring-length\fP 53 | \fBtrim-string\fP 54 | \fBupper-string\fP 55 | \fBwrite-string\fP 56 | See all 57 | \fBdocumentation\fP 58 | -------------------------------------------------------------------------------- /docs/current-row.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | current-row \- (database) 4 | .SH PURPOSE 5 | Get or print out the row number of a current row in the result-set of a query. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | current-row [ to ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | Without "to" clause, current-row will print out the current row number. First row is numbered 1. With "to" clause, the row number is stored into variable . current-row must be within a \fBrun-query\fP loop, and it always refers to the most inner one. 19 | 20 | .SH EXAMPLES 21 | Display row number before a line with first and last name for each employee: 22 | 23 | .RS 4 24 | .EX 25 | 26 | run-query @mydb="select firstName, lastName from employee" output firstName, lastName 27 | @Row #<>
28 | p-out firstName 29 | @, 30 | p-out lastName 31 | @
32 | end-query 33 | 34 | .EE 35 | .RE 36 | 37 | .SH SEE ALSO 38 | Database 39 | 40 | \fBbegin-transaction\fP 41 | \fBcommit-transaction\fP 42 | \fBcurrent-row\fP 43 | \fBdatabase-config-file\fP 44 | \fBdb-error\fP 45 | \fBmariadb-database\fP 46 | \fBpostgresql-database\fP 47 | \fBrollback-transaction\fP 48 | \fBrun-query\fP 49 | \fBsqlite-database\fP 50 | See all 51 | \fBdocumentation\fP 52 | -------------------------------------------------------------------------------- /docs/db-error.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | db-error \- (database 4 | error-handling) 5 | .SH PURPOSE 6 | Either exit request or continue processing when there is an error in a database statement. 7 | 8 | .SH SYNTAX 9 | 10 | .RS 4 11 | .EX 12 | 13 | db-error [ @ ] ( exit | continue ) 14 | 15 | .EE 16 | .RE 17 | 18 | .SH DESCRIPTION 19 | db-error sets the response to the failure of database statements. You can change this response at run-time with each execution of db-error. 20 | 21 | When a database statement (like \fBrun-query\fP) fails, Golf will either exit request processing if "exit" is used, or continue if "continue" is used. "Exiting" is equivalent to calling \fBreport-error\fP with the message containing details about the error. "Continuing" means that your program will continue but you should examine error code (see for instance "error" clause in \fBrun-query\fP). 22 | 23 | The default action is "exit". You can switch back and forth between "exit" and "continue". Typically, "exit" is preferable because errors in database statemets generally mean application or setup issues, however "continue" may be used when application wants to attempt to recover from errors or perform other actions. 24 | 25 | Note that you can override the effect of db-error for a specific database statement by using clauses like "on-error-continue" and "on-error-exit" in \fBrun-query\fP. 26 | 27 | .LP 28 | .B DATABASE 29 | .LP 30 | 31 | is specified in "@" clause and is the name of the \fBdatabase-config-file\fP. If omitted, your program must use exactly one database (see --db option in \fBgg\fP). 32 | 33 | .SH EXAMPLES 34 | The following will not exit when errors happen going forward, but rather continue execution (and you should check every error henceforth): 35 | 36 | .RS 4 37 | .EX 38 | 39 | db-error @mydb continue 40 | 41 | .EE 42 | .RE 43 | 44 | .SH SEE ALSO 45 | Database 46 | 47 | \fBbegin-transaction\fP 48 | \fBcommit-transaction\fP 49 | \fBcurrent-row\fP 50 | \fBdatabase-config-file\fP 51 | \fBdb-error\fP 52 | \fBmariadb-database\fP 53 | \fBpostgresql-database\fP 54 | \fBrollback-transaction\fP 55 | \fBrun-query\fP 56 | \fBsqlite-database\fP 57 | Error handling 58 | 59 | \fBdb-error\fP 60 | \fBerror-code\fP 61 | \fBerror-handling\fP 62 | \fBreport-error\fP 63 | See all 64 | \fBdocumentation\fP 65 | -------------------------------------------------------------------------------- /docs/decode-base64.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | decode-base64 \- (base64) 4 | .SH PURPOSE 5 | Base64 decode. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | decode-base64 to \\ 13 | [ input-length ] 14 | 15 | .EE 16 | .RE 17 | 18 | .SH DESCRIPTION 19 | decode-base64 will decode string into , which can be binary string. 20 | 21 | If "input-length" clause is used, then is the number of bytes decoded, otherwise the entirety of is decoded. 22 | 23 | The result is stored in (in "to" clause). 24 | 25 | Note that the string to decode can have whitespaces before it (such as spaces or tabs), and whitespaces and new lines after it, which will all be ignored for the purpose of decoding. 26 | 27 | .SH EXAMPLES 28 | See \fBencode-base64\fP. 29 | .SH SEE ALSO 30 | Base64 31 | 32 | \fBdecode-base64\fP 33 | \fBencode-base64\fP 34 | See all 35 | \fBdocumentation\fP 36 | -------------------------------------------------------------------------------- /docs/decode-hex.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | decode-hex \- (hex-encoding) 4 | .SH PURPOSE 5 | Decode hexadecimal string into data. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | decode-hex to \\ 13 | [ input-length ] 14 | 15 | .EE 16 | .RE 17 | 18 | .SH DESCRIPTION 19 | decode-hex will decode hexadecimal string to string given in "to" clause. 20 | 21 | must consist of an even number of digits 0-9 and letters A-F or a-f. The length of may be given by number in "input-length" clause, otherwise it is assumed to be the string length of . 22 | 23 | .SH EXAMPLES 24 | Get the original binary data from a hexadecimal string "hexdata". The output string "binout" is created: 25 | 26 | .RS 4 27 | .EX 28 | 29 | set-string hexdata = "0041000F414200" 30 | decode-hex hexdata to binout 31 | 32 | .EE 33 | .RE 34 | 35 | The value of "binout" will be binary data equal to this C literal: 36 | 37 | .RS 4 38 | .EX 39 | 40 | "\ex00""A""\ex00""\exF""AB""\ex00""\ex04" 41 | 42 | .EE 43 | .RE 44 | 45 | .SH SEE ALSO 46 | Hex encoding 47 | 48 | \fBdecode-hex\fP 49 | \fBencode-hex\fP 50 | See all 51 | \fBdocumentation\fP 52 | -------------------------------------------------------------------------------- /docs/decode-url.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | decode-url \- (URL-encoding) 4 | .SH PURPOSE 5 | Decode URL-encoded string. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | decode-url [ input-length ] [ status ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | decode-url will decode (created by \fBencode-url\fP or other URL-encoding software) and store the result back into . If you need unchanged, make a copy of it first with \fBcopy-string\fP. in "input-length" clause specifies the number of bytes to decode; if omitted or negative, it is the string length of . 19 | 20 | All encoded values (starting with %) are decoded, and "+" (plus sign) is converted to space. 21 | 22 | number (in "status" clause) is GG_OKAY if all bytes decoded successfully, or in case of an error it is the index of the byte that could not be decoded (first byte is indexed "0"). If there is an error (for example hexadecimal value following % is invalid), the decoding stops and whatever was decoded up to that point is the result. 23 | 24 | .SH EXAMPLES 25 | Decode URL-encoded string "str", after which it will hold a decoded string. 26 | 27 | .RS 4 28 | .EX 29 | 30 | decode-url str 31 | 32 | .EE 33 | .RE 34 | 35 | .SH SEE ALSO 36 | URL encoding 37 | 38 | \fBdecode-url\fP 39 | \fBencode-url\fP 40 | See all 41 | \fBdocumentation\fP 42 | -------------------------------------------------------------------------------- /docs/decode-web.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | decode-web \- (web-encoding) 4 | .SH PURPOSE 5 | Decode web(HTML)-encoded string. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | decode-web [ input-length ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | decode-web will decode (created by \fBencode-web\fP or other web-encoding software) and store the result back into it. If you need unchanged, make a copy of it first with \fBcopy-string\fP. To decode only a number of leading bytes in , use "input-length" clause and specify . 19 | 20 | See \fBencode-web\fP. 21 | 22 | .SH EXAMPLES 23 | Decode web-encoded string "str", after which it will hold a decoded string. 24 | 25 | .RS 4 26 | .EX 27 | 28 | decode-web str 29 | 30 | .EE 31 | .RE 32 | 33 | .SH SEE ALSO 34 | Web encoding 35 | 36 | \fBdecode-web\fP 37 | \fBencode-web\fP 38 | See all 39 | \fBdocumentation\fP 40 | -------------------------------------------------------------------------------- /docs/delete-cookie.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | delete-cookie \- (cookies) 4 | .SH PURPOSE 5 | Deletes a cookie. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | delete-cookie [ path ] [ status ] [ secure ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | delete-cookie marks a cookie named for deletion, so it is sent back in the reply telling the client (such as browser) to delete it. 19 | 20 | Newer client implementations require a cookie deletion to use a secure context if the cookie is considered secure, and it is recommended to use "secure" clause to delete such a cookie. This is the case when either "secure" clause is used without boolean variable , or if evaluates to true. 21 | 22 | is a cookie that was either received from the client as a part of the request, or was added with \fBset-cookie\fP. 23 | 24 | A cookie can be deleted before or after header is sent out (see \fBout-header\fP). However a cookie must be deleted prior to outputting any actual response (such as with \fBoutput-statement\fP or \fBp-out\fP for example), or the request will error out (see \fBerror-handling\fP). 25 | 26 | (in "status" clause) is a number that will be GG_ERR_EXIST if the cookie did not exist, or GG_OKAY if it did. 27 | 28 | The same cookie name may be stored under different URL paths. You can use "path" clause to specify to ensure the desired cookie is deleted. 29 | 30 | .SH EXAMPLES 31 | 32 | .RS 4 33 | .EX 34 | 35 | delete-cookie "my_cookie" 36 | set-bool is_secure = true 37 | delete-cookie "my_cookie" path "/path" secure is_secure 38 | 39 | .EE 40 | .RE 41 | 42 | .SH SEE ALSO 43 | Cookies 44 | 45 | \fBdelete-cookie\fP 46 | \fBget-cookie\fP 47 | \fBset-cookie\fP 48 | See all 49 | \fBdocumentation\fP 50 | -------------------------------------------------------------------------------- /docs/delete-dir.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | delete-dir \- (directories) 4 | .SH PURPOSE 5 | Delete directory. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | delete-dir [ status ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | delete-dir will delete , which is a string that may be an absolute or relative path. 19 | 20 | If "status" clause is used, then number is GG_OKAY if succeeded, GG_ERR_EXIST if directory is not empty, or GG_ERR_FAILED for other errors (in which case you can use "errno" clause in \fBget-req\fP to find the specific reason why). 21 | 22 | .SH EXAMPLES 23 | 24 | .RS 4 25 | .EX 26 | 27 | delete-dir "/home/user/some_dir" 28 | 29 | .EE 30 | .RE 31 | 32 | .SH SEE ALSO 33 | Directories 34 | 35 | \fBchange-dir\fP 36 | \fBchange-mode\fP 37 | \fBdelete-dir\fP 38 | \fBdirectories\fP 39 | \fBnew-dir\fP 40 | See all 41 | \fBdocumentation\fP 42 | -------------------------------------------------------------------------------- /docs/delete-fifo.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | delete-fifo \- (FIFO) 4 | .SH PURPOSE 5 | Delete FIFO list elements up to the last one read, including. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | delete-fifo 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | delete-fifo will delete all leading elements from the FIFO up to the last one read, including. was created by \fBnew-fifo\fP. 19 | 20 | Right after \fBrewind-fifo\fP, no element was read yet, and delete-fifo will have no effect. After any \fBread-fifo\fP, delete-fifo wil delete all elements up to the element read, including that element. 21 | 22 | .SH EXAMPLES 23 | 24 | .RS 4 25 | .EX 26 | 27 | new-fifo mylist 28 | 29 | // Add data to the list 30 | write-fifo mylist key "key1" value "value1" 31 | write-fifo mylist key "some2" value "other2" 32 | 33 | // Get first data from the list 34 | read-fifo mylist key k value v 35 | 36 | // Delete first element from the list, so list will have only "some2" key 37 | delete-fifo mylist 38 | 39 | .EE 40 | .RE 41 | 42 | .SH SEE ALSO 43 | FIFO 44 | 45 | \fBdelete-fifo\fP 46 | \fBnew-fifo\fP 47 | \fBpurge-fifo\fP 48 | \fBread-fifo\fP 49 | \fBrewind-fifo\fP 50 | \fBwrite-fifo\fP 51 | See all 52 | \fBdocumentation\fP 53 | -------------------------------------------------------------------------------- /docs/delete-file.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | delete-file \- (files) 4 | .SH PURPOSE 5 | Deletes a file. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | delete-file [ status ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | File specified with is deleted. can be given with an absolute path or relative to the application home directory (see \fBdirectories\fP). 19 | 20 | If "status" is specified, the status is stored into . The status is GG_OKAY on success or if the file did not exist, and GG_ERR_DELETE on failure. 21 | 22 | .SH EXAMPLES 23 | 24 | .RS 4 25 | .EX 26 | 27 | delete-file "/home/user/some_file" status st 28 | 29 | .EE 30 | .RE 31 | 32 | .SH SEE ALSO 33 | Files 34 | 35 | \fBchange-mode\fP 36 | \fBclose-file\fP 37 | \fBcopy-file\fP 38 | \fBdelete-file\fP 39 | \fBfile-position\fP 40 | \fBfile-storage\fP 41 | \fBfile-uploading\fP 42 | \fBlock-file\fP 43 | \fBopen-file\fP 44 | \fBread-file\fP 45 | \fBread-line\fP 46 | \fBrename-file\fP 47 | \fBstat-file\fP 48 | \fBtemporary-file\fP 49 | \fBuniq-file\fP 50 | \fBunlock-file\fP 51 | \fBwrite-file\fP 52 | See all 53 | \fBdocumentation\fP 54 | -------------------------------------------------------------------------------- /docs/delete-lifo.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | delete-lifo \- (LIFO) 4 | .SH PURPOSE 5 | Delete LIFO list elements. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | delete-lifo 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | delete-lifo will delete the most recently added elements to the LIFO up to the last one read, including. was created by \fBnew-lifo\fP. 19 | 20 | Right after \fBrewind-lifo\fP, no element was read yet, and delete-lifo will have no effect. Note that \fBwrite-lifo\fP also performs an implicit \fBrewind-lifo\fP. 21 | 22 | After any \fBread-lifo\fP, delete-lifo wil delete all elements up to the element read, including that element. 23 | 24 | .SH EXAMPLES 25 | 26 | .RS 4 27 | .EX 28 | 29 | new-lifo mylist 30 | 31 | // Add data to the list 32 | write-lifo mylist key "key1" value "value1" 33 | write-lifo mylist key "some2" value "other2" 34 | 35 | // Get first data from the list, it will be "some2" key 36 | read-lifo mylist key k value v 37 | 38 | // Delete first element from the list, so list will have only "key1" key 39 | delete-lifo mylist 40 | 41 | .EE 42 | .RE 43 | 44 | .SH SEE ALSO 45 | LIFO 46 | 47 | \fBdelete-lifo\fP 48 | \fBnew-lifo\fP 49 | \fBpurge-lifo\fP 50 | \fBread-lifo\fP 51 | \fBrewind-lifo\fP 52 | \fBwrite-lifo\fP 53 | See all 54 | \fBdocumentation\fP 55 | -------------------------------------------------------------------------------- /docs/delete-list.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | delete-list \- (linked-list) 4 | .SH PURPOSE 5 | Delete current linked list element. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | delete-list [ status ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | delete-list will delete current element in linked created with \fBnew-list\fP. A current list element is the one that will be subject to statements like \fBread-list\fP and \fBwrite-list\fP. See \fBposition-list\fP for more details on the current element. 19 | 20 | (in "status" clause) is GG_OKAY if element is deleted, or GG_ERR_EXIST if could not delete element (this can happen if the list is empty, or if current list element is beyond the last element, such as for instance if "end" clause is used in position-list statement). 21 | 22 | Once an element is deleted, the current element becomes either the next one (if the current element wasn't the last one), or the previous one (if the current element was the last one). 23 | 24 | .SH EXAMPLES 25 | 26 | .RS 4 27 | .EX 28 | 29 | delete-list mylist status st 30 | 31 | .EE 32 | .RE 33 | 34 | .SH SEE ALSO 35 | Linked list 36 | 37 | \fBdelete-list\fP 38 | \fBget-list\fP 39 | \fBnew-list\fP 40 | \fBposition-list\fP 41 | \fBpurge-list\fP 42 | \fBread-list\fP 43 | \fBwrite-list\fP 44 | See all 45 | \fBdocumentation\fP 46 | -------------------------------------------------------------------------------- /docs/delete-string.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | delete-string \- (strings) 4 | .SH PURPOSE 5 | Free string memory. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | delete-string 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | delete-string frees variable previously allocated by a Golf statement. 19 | 20 | Note that freeing memory is in most cases unnecessary as Golf will automatically do so at the end of each request. You should have a good reason for using delete-string otherwise. 21 | 22 | Golf keeps count of references for process-scoped memory (see \fBmemory-handling\fP), and such memory will be deleted at the end of the request once reference count reaches zero. 23 | 24 | For non-process-scoped memory, if is referenced by other variables, then may not be deleted. Regardless of whether the memory referenced by is actually deleted or not, becomes an empty string ("") after delete-string. 25 | 26 | .SH EXAMPLES 27 | Allocate and free random string: 28 | 29 | .RS 4 30 | .EX 31 | 32 | random-string to ran_str 33 | \[char46].. 34 | delete-string ran_str 35 | 36 | .EE 37 | .RE 38 | 39 | Free string allocated by write-string (consisting of 100 "Hello World"s): 40 | 41 | .RS 4 42 | .EX 43 | 44 | write-string ws 45 | start-loop repeat 100 46 | @Hello World 47 | end-loop 48 | end-write-string 49 | \[char46].. 50 | delete-string ws 51 | 52 | .EE 53 | .RE 54 | 55 | .SH SEE ALSO 56 | Strings 57 | 58 | \fBconcatenate-strings\fP 59 | \fBcopy-string\fP 60 | \fBcount-substring\fP 61 | \fBdelete-string\fP 62 | \fBlower-string\fP 63 | \fBread-split\fP 64 | \fBreplace-string\fP 65 | \fBset-string\fP 66 | \fBsplit-string\fP 67 | \fBstring-length\fP 68 | \fBtrim-string\fP 69 | \fBupper-string\fP 70 | \fBwrite-string\fP 71 | See all 72 | \fBdocumentation\fP 73 | -------------------------------------------------------------------------------- /docs/delete-tree.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | delete-tree \- (tree) 4 | .SH PURPOSE 5 | Delete a node from a tree. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | delete-tree key \\ 13 | [ status ] \\ 14 | [ value ] \\ 15 | 16 | .EE 17 | .RE 18 | 19 | .SH DESCRIPTION 20 | delete-tree will search for string and if found, delete its node (including the key in it), set (in "value" clause) to node's value, and set number (in "status" clause) to GG_OKAY. If is not found, will be GG_ERR_EXIST. If is not GG_OKAY, is unchanged. 21 | 22 | .SH EXAMPLES 23 | Delete node with key "123", and obtain its value: 24 | 25 | .RS 4 26 | .EX 27 | 28 | set-string k = "123" 29 | delete-tree mytree key k value val status st 30 | if-true st not-equal GG_OKAY 31 | @Could not find key <> 32 | exit-handler 33 | end-if 34 | // display key/value deleted 35 | @Deleted key <> with value <> 36 | // delete the original value 37 | delete-string val 38 | 39 | .EE 40 | .RE 41 | 42 | .SH SEE ALSO 43 | Tree 44 | 45 | \fBdelete-tree\fP 46 | \fBget-tree\fP 47 | \fBnew-tree\fP 48 | \fBpurge-tree\fP 49 | \fBread-tree\fP 50 | \fBuse-cursor\fP 51 | \fBwrite-tree\fP 52 | See all 53 | \fBdocumentation\fP 54 | -------------------------------------------------------------------------------- /docs/do-once.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | do-once \- (program-flow) 4 | .SH PURPOSE 5 | Execute statements only once in a process. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | do-once 13 | 14 | ... 15 | end-do-once 16 | 17 | .EE 18 | .RE 19 | 20 | .SH DESCRIPTION 21 | do-once will execute only once in a single process regardless of how many requests that process serves. end with end-do-once. The first time a process reaches do-once, will execute; in all subsequent cases the program control will skip to immediately after end-do-once. 22 | 23 | do-once cannot be nested, but otherwise can be used any number of times. 24 | 25 | Typical use of do-once may be making any calls that need to be performed only once per process, or it may be a one-time setup of process-scoped variables, or anything else that needs to execute just once for all requests served by the same process. 26 | 27 | execute in the nested scope relative to the code surrounding do-once/end-do-once, except that any process-scoped variables are created in the same scope as the code surrounding do-once/end-do-once; this simplifies creation of process-scoped variables, if needed. 28 | 29 | .SH EXAMPLES 30 | In this example, a process-scoped hash (that is available to multiple requests of a single process) is created in the very first request a process serves and data is written to it; the subsequent requests do not create a new hash but rather just write to it. 31 | 32 | .RS 4 33 | .EX 34 | 35 | \[char46].. 36 | do-once 37 | new-hash my_hash hash-size 1024 process-scope 38 | end-do-once 39 | write-hash my_hash key my_key value my_data 40 | ... 41 | 42 | .EE 43 | .RE 44 | 45 | .SH SEE ALSO 46 | Program flow 47 | 48 | \fBbreak-loop\fP 49 | \fBcode-blocks\fP 50 | \fBcontinue-loop\fP 51 | \fBdo-once\fP 52 | \fBexit-handler\fP 53 | \fBif-defined\fP 54 | \fBif-true\fP 55 | \fBreturn-handler\fP 56 | \fBset-bool\fP 57 | \fBstart-loop\fP 58 | See all 59 | \fBdocumentation\fP 60 | -------------------------------------------------------------------------------- /docs/encode-base64.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | encode-base64 \- (base64) 4 | .SH PURPOSE 5 | Base64 encode. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | encode-base64 to \\ 13 | [ input-length ] 14 | 15 | .EE 16 | .RE 17 | 18 | .SH DESCRIPTION 19 | encode-base64 will encode string into base64 string . 20 | 21 | If "input-length" clause is used, then is the number of bytes encoded, otherwise the entirety of is encoded. 22 | 23 | The result is stored in (in "to" clause). 24 | 25 | Base64-encoded strings are often used where binary data needs to be in a format that complies with certain text-based protocols, such as in attaching documents in email, or embedding binary documents (such as "JPG" images for example) in web pages with "data:image/jpg;base64..." specified, etc. 26 | 27 | .SH EXAMPLES 28 | An example that encodes a string, decodes, and finally checks if they match: 29 | 30 | .RS 4 31 | .EX 32 | 33 | // Original string, generally this would be binary data in most cases 34 | set-string dt =" oh well " 35 | 36 | // Encode in base64 37 | encode-base64 dt to out_dt 38 | 39 | decode-base64 out_dt to new_dt 40 | 41 | if-true dt equal new_dt 42 | @Success! 43 | else-if 44 | @Failure! 45 | end-if 46 | 47 | .EE 48 | .RE 49 | 50 | In the next example, "input-length" clause is used, and only a partial of the input string is encoded, then later compared to the original: 51 | 52 | .RS 4 53 | .EX 54 | 55 | // Original string, generally this would be binary data in most cases 56 | set-string dt =" oh well " 57 | 58 | // Encode in base64, encode only 6 bytes 59 | encode-base64 dt input-length 6 to out_dt 60 | 61 | decode-base64 out_dt to new_dt 62 | 63 | // Get length of decoded string 64 | string-length new_dt to new_len 65 | 66 | if-true new_len not-equal 6 67 | @Failure! 68 | else-if 69 | @Success! 70 | end-if 71 | 72 | if-true dt equal new_dt length new_len 73 | @Success! 74 | else-if 75 | @Failure! [<>] [<>] 76 | end-if 77 | 78 | .EE 79 | .RE 80 | 81 | .SH SEE ALSO 82 | Base64 83 | 84 | \fBdecode-base64\fP 85 | \fBencode-base64\fP 86 | See all 87 | \fBdocumentation\fP 88 | -------------------------------------------------------------------------------- /docs/encode-hex.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | encode-hex \- (hex-encoding) 4 | .SH PURPOSE 5 | Encode data into hexadecimal string. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | encode-hex to \\ 13 | [ input-length ] \\ 14 | [ prefix ] 15 | 16 | .EE 17 | .RE 18 | 19 | .SH DESCRIPTION 20 | encode-hex will encode string to hexadecimal string given in "to" clause which consists of digits "0"-"9" and letters "a"-"f". 21 | 22 | The length of to encode may be given with number in "input-length" clause; if not the whole string is used. If you wish to prefix the output with a string , you can specify it in "prefix" clause with ; otherwise no prefix is prepended. 23 | 24 | .SH EXAMPLES 25 | Create hexadecimal string from binary data "mydata" of length 7, prefixed with string "\\\\ex" (which is typically needed for PostgreSQL binary input to queries). The output string "hexout" is created: 26 | 27 | .RS 4 28 | .EX 29 | 30 | set-string mydata = "\ex00""A""\ex00""\exF""AB""\ex00""\ex04" 31 | encode-hex mydata to hexout input-length 7 prefix "\\\\ex" 32 | 33 | .EE 34 | .RE 35 | 36 | The value of "hexout" will be: 37 | 38 | .RS 4 39 | .EX 40 | 41 | \\ex0041000F414200 42 | 43 | .EE 44 | .RE 45 | 46 | .SH SEE ALSO 47 | Hex encoding 48 | 49 | \fBdecode-hex\fP 50 | \fBencode-hex\fP 51 | See all 52 | \fBdocumentation\fP 53 | -------------------------------------------------------------------------------- /docs/encode-url.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | encode-url \- (URL-encoding) 4 | .SH PURPOSE 5 | URL-encode string. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | encode-url to \\ 13 | [ input-length ] 14 | 15 | .EE 16 | .RE 17 | 18 | .SH DESCRIPTION 19 | encode-url URL-encodes and stores the result in . 20 | 21 | in "input-length" clause lets you specify the number of bytes in that will be encoded - if not specified or negative, it is the string length. 22 | 23 | All bytes except alphanumeric and those from "-._~" (i.e. dash, dot, underscore and tilde) are encoded. 24 | 25 | .SH EXAMPLES 26 | In this example, a string "str" is URL encoded and the result is in a "result" string variable: 27 | 28 | .RS 4 29 | .EX 30 | 31 | set-string str=" x=y?z& " 32 | encode-url str to result 33 | 34 | .EE 35 | .RE 36 | 37 | The "result" is "%20%20x%3Dy%3Fz%26%20%20". 38 | .SH SEE ALSO 39 | URL encoding 40 | 41 | \fBdecode-url\fP 42 | \fBencode-url\fP 43 | See all 44 | \fBdocumentation\fP 45 | -------------------------------------------------------------------------------- /docs/encode-web.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | encode-web \- (web-encoding) 4 | .SH PURPOSE 5 | Web(HTML)-encode string. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | encode-web to \\ 13 | [ input-length ] 14 | 15 | .EE 16 | .RE 17 | 18 | .SH DESCRIPTION 19 | encode-web encodes so it can be used in a HTML-like markup text (such as a web page or an XML/XHTML document), and stores the result in . 20 | 21 | You can encode only the first bytes, given by "input-length" clause. 22 | 23 | .SH EXAMPLES 24 | In this example, a string "str" will be web-encoded and the result is in "result" variable: 25 | 26 | .RS 4 27 | .EX 28 | 29 | set-string str=" xz&\[char92]"' " 30 | encode-web str to result 31 | 32 | .EE 33 | .RE 34 | 35 | The "result" is " x<y>z&"' ". 36 | .SH SEE ALSO 37 | Web encoding 38 | 39 | \fBdecode-web\fP 40 | \fBencode-web\fP 41 | See all 42 | \fBdocumentation\fP 43 | -------------------------------------------------------------------------------- /docs/error-code.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | error-code \- Golf documentation (error-handling) 4 | .SH DESCRIPTION 5 | Many Golf statements return status with GG_ERR_... error codes, which are generally descriptive to a point. Such status may not as detailed as the operating system "errno" variable, however you can use "errno" clause in \fBget-req\fP statement to obtain the last known errno value from aforementioned statements. You should obtain this value as soon as possible after the statement because another statement may set it afterwards. 6 | 7 | In the following example, a directory is attempted to be deleted via \fBdelete-file\fP, which will fail with GG_ERR_DELETE - however you can get a more specific code via "errno" (which in this case is "21", or "EISDIR", which means that it cannot delete a directory with this statement): 8 | 9 | .RS 4 10 | .EX 11 | 12 | delete-file "some_directory" status stc 13 | if-true stc equal GG_ERR_DELETE 14 | get-req errno to e 15 | @Cannot delete file 16 | pf-out "Error %ld\en", e 17 | end-if 18 | 19 | .EE 20 | .RE 21 | 22 | Note that with some GG_ERR_... codes, the "errno" clause in get-req may return 0. This means the error was detected by Golf and not reported by the operating system. 23 | 24 | You can use standard Linux constants, as defined in C "errno.h" include file to compare the error code obtained with get-req. For instance, you can use constants like EACCES or EEXIST. To see what's the meaning of errno number or name, use standard Linux utility "errno". 25 | .SH SEE ALSO 26 | Error handling 27 | 28 | \fBdb-error\fP 29 | \fBerror-code\fP 30 | \fBerror-handling\fP 31 | \fBreport-error\fP 32 | See all 33 | \fBdocumentation\fP 34 | -------------------------------------------------------------------------------- /docs/error-handling.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | error-handling \- Golf documentation (error-handling) 4 | .SH DESCRIPTION 5 | 6 | .LP 7 | .B WHEN YOUR PROGRAM ERRORS OUT 8 | .LP 9 | 10 | "Erroring out" means a process handling a request has encountered a difficulty that cannot be handled and it will either: 11 | 12 | .RS 4 13 | \[bu] 14 | Skip the rest of the request, and move on quickly to handle the next request without exiting. Most errors are like this, for example your program has attempted to access memory outside of what's allocated, or you have called \fBreport-error\fP statement. 15 | 16 | .RE 17 | 18 | .RS 4 19 | \[bu] 20 | Stop and exit, and it may be automatically restarted if it's a \fBservice\fP. For instance, the process could be out of memory, or the database is permanently down and connection cannot be re-established. 21 | .RE 22 | . 23 | Note that if your program is \fBcommand-line\fP, it will exit in any case since it handles a single request anyway. 24 | .RE 25 | 26 | 27 | .LP 28 | .B WHEN THERE IS A PROBLEM IN GOLF 29 | .LP 30 | 31 | If there is a fatal internal error (i.e. error in Golf code itself that cannot be handled), it will be caught by Golf, and the process will end. If your process is started with \fBmgrg\fP, it may be automatically restarted. 32 | 33 | .LP 34 | .B LOGGING THE ERROR 35 | .LP 36 | 37 | Regardless of the type of error and regardless of whether the process exits or not, the error is logged and the program stack with full source code lines (see \fBgg\fP for including debug information) will be written to backtrace file (use -e option of \fBgg\fP to obtain its location). Note that the program stack is logged only if debugging info is present (i.e. if installed from package you must install debugging package as well). 38 | 39 | You can see the list of last N errors (and the location of file containing backtrace for them) by using \fBgg\fP, for instance to see the last 3 errors: 40 | 41 | .RS 4 42 | .EX 43 | 44 | gg -e 3 45 | 46 | .EE 47 | .RE 48 | 49 | .SH SEE ALSO 50 | Error handling 51 | 52 | \fBdb-error\fP 53 | \fBerror-code\fP 54 | \fBerror-handling\fP 55 | \fBreport-error\fP 56 | See all 57 | \fBdocumentation\fP 58 | -------------------------------------------------------------------------------- /docs/exit-handler.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | exit-handler \- (program-flow) 4 | .SH PURPOSE 5 | Exit current request processing. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | exit-handler [ ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | Exits current request by transferring control directly after the top-level \fBrequest\fP dispatcher. If there is an \fBafter-handler\fP, it will still execute, unless exit-handler is called from \fBbefore-handler\fP. 19 | 20 | number is a request status returned to the caller (see \fBhandler-status\fP); if not specified, then it's the value specified in the last executed handler-status statement; if none executed, then it's 0. 21 | 22 | .SH EXAMPLES 23 | Returning status of 20: 24 | 25 | .RS 4 26 | .EX 27 | 28 | begin-handler /req-handler public 29 | ... 30 | handler-status 20 31 | ... 32 | exit-handler 33 | ... 34 | end-handler 35 | 36 | .EE 37 | .RE 38 | 39 | Returning status of 0: 40 | 41 | .RS 4 42 | .EX 43 | 44 | begin-handler /req-handler public 45 | ... 46 | exit-handler 47 | ... 48 | end-handler 49 | 50 | .EE 51 | .RE 52 | 53 | Returning status of 10: 54 | 55 | .RS 4 56 | .EX 57 | 58 | begin-handler /req-handler public 59 | ... 60 | exit-handler 10 61 | ... 62 | end-handler 63 | 64 | .EE 65 | .RE 66 | 67 | .SH SEE ALSO 68 | Program flow 69 | 70 | \fBbreak-loop\fP 71 | \fBcode-blocks\fP 72 | \fBcontinue-loop\fP 73 | \fBdo-once\fP 74 | \fBexit-handler\fP 75 | \fBif-defined\fP 76 | \fBif-true\fP 77 | \fBreturn-handler\fP 78 | \fBset-bool\fP 79 | \fBstart-loop\fP 80 | See all 81 | \fBdocumentation\fP 82 | -------------------------------------------------------------------------------- /docs/extended-mode.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | extended-mode \- (C-language) 4 | .SH PURPOSE 5 | Use external libraries or C code with Golf. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | extended-mode 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | extended-mode, when specified as a very first statement in .golf source file, allows for use of \fBcall-extended\fP statement. 19 | 20 | .SH EXAMPLES 21 | 22 | .RS 4 23 | .EX 24 | 25 | extended-mode 26 | 27 | begin-handler /my-handler public 28 | ... 29 | call-extended factorial (10, &fact) 30 | ... 31 | end-handler 32 | 33 | .EE 34 | .RE 35 | 36 | .SH SEE ALSO 37 | C language 38 | 39 | \fBcall-extended\fP 40 | \fBextended-mode\fP 41 | \fBweb-framework-for-C-programming-language\fP 42 | See all 43 | \fBdocumentation\fP 44 | -------------------------------------------------------------------------------- /docs/file-position.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | file-position \- (files) 4 | .SH PURPOSE 5 | Set a position or get a current position for an open file. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | file-position file-id \\ 13 | ( set ) | ( get ) \\ 14 | [ status ] 15 | 16 | .EE 17 | .RE 18 | 19 | .SH DESCRIPTION 20 | file-position will set or get position for a file opened with \fBopen-file\fP, where is an open file identifier. 21 | 22 | If "set" clause is used, file position is set to (with 0 being the first byte). 23 | 24 | If "get" clause is used, file position is obtained in (with 0 being the first byte). 25 | 26 | number in "status" clause will be GG_OKAY if set/get succeeded, GG_ERR_OPEN if file not open, or GG_ERR_POSITION if not. 27 | 28 | Note that setting position past the last byte of file is okay for writing - in this case the bytes between the end of file and the are filled with null-bytes when the write operation occurs. 29 | 30 | .SH EXAMPLES 31 | Open file "testwrite" and set file byte position to 100, then obtain it later: 32 | 33 | .RS 4 34 | .EX 35 | 36 | open-file "testwrite" file-id nf 37 | file-position file-id nf set 100 38 | \[char46].. 39 | file-position file-id nf get pos 40 | 41 | .EE 42 | .RE 43 | 44 | See also \fBopen-file\fP. 45 | .SH SEE ALSO 46 | Files 47 | 48 | \fBchange-mode\fP 49 | \fBclose-file\fP 50 | \fBcopy-file\fP 51 | \fBdelete-file\fP 52 | \fBfile-position\fP 53 | \fBfile-storage\fP 54 | \fBfile-uploading\fP 55 | \fBlock-file\fP 56 | \fBopen-file\fP 57 | \fBread-file\fP 58 | \fBread-line\fP 59 | \fBrename-file\fP 60 | \fBstat-file\fP 61 | \fBtemporary-file\fP 62 | \fBuniq-file\fP 63 | \fBunlock-file\fP 64 | \fBwrite-file\fP 65 | See all 66 | \fBdocumentation\fP 67 | -------------------------------------------------------------------------------- /docs/file-storage.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | file-storage \- Golf documentation (files) 4 | .SH DESCRIPTION 5 | Golf provides a file directory that you can use for any general purpose, including for storing \fBtemporary-file\fPs. This directory is also used for automatic upload of files from clients. It provides a two-tier directory system, with sub-directories automatically created to spread the files for faster access. 6 | 7 | Files in Golf file directory are located in the sub-directories of: 8 | 9 | .RS 4 10 | .EX 11 | 12 | /var/lib/gg//app/file 13 | 14 | .EE 15 | .RE 16 | 17 | If you wish to place this directory in another physical location, see \fBgg\fP. 18 | 19 | You can create files here by means of \fBuniq-file\fP, where a new unique file is created - with the file name made available to you. This directory is also used for uploading of files from clients (such as web browsers or mobile device cameras) - the uploading is handled automatically by Golf (see \fBget-param\fP). 20 | 21 | In general, a number of sub-directories is created within the file directory that contain files, which allows for billions of files to be kept. This scheme also allows for faster access to file nodes due to relatively low number of sub-directories and files randomly spread per each such sub-directory. The random spreading of files across subdirectories is done automatically. 22 | 23 | Do not rename file names or sub-directory names stored under file directory. 24 | .SH SEE ALSO 25 | Files 26 | 27 | \fBchange-mode\fP 28 | \fBclose-file\fP 29 | \fBcopy-file\fP 30 | \fBdelete-file\fP 31 | \fBfile-position\fP 32 | \fBfile-storage\fP 33 | \fBfile-uploading\fP 34 | \fBlock-file\fP 35 | \fBopen-file\fP 36 | \fBread-file\fP 37 | \fBread-line\fP 38 | \fBrename-file\fP 39 | \fBstat-file\fP 40 | \fBtemporary-file\fP 41 | \fBuniq-file\fP 42 | \fBunlock-file\fP 43 | \fBwrite-file\fP 44 | See all 45 | \fBdocumentation\fP 46 | -------------------------------------------------------------------------------- /docs/finish-output.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | finish-output \- (output) 4 | .SH PURPOSE 5 | Finish the output. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | finish-output 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | finish-output will flush out and conclude all output (see \fBoutput-statement\fP). Any such output afterwards will silently fail to do so. As far as the client is concerned, all the output is complete. 19 | 20 | This statement is useful when you need to continue work after the output is complete. For example, if the task performed is a long-running one, you can inform the client that the job has started, and then take any amount of time to actually complete the job, without worrying about client timeouts. The client can inquire about the job status via a different request, or be informed via email etc. 21 | 22 | .SH EXAMPLES 23 | 24 | .RS 4 25 | .EX 26 | 27 | finish-output 28 | 29 | .EE 30 | .RE 31 | 32 | .SH SEE ALSO 33 | Output 34 | 35 | \fBfinish-output\fP 36 | \fBflush-output\fP 37 | \fBoutput-statement\fP 38 | \fBpf-out\fP 39 | \fBpf-url\fP 40 | \fBpf-web\fP 41 | \fBp-num\fP 42 | \fBp-out\fP 43 | \fBp-path\fP 44 | \fBp-source-file\fP 45 | \fBp-source-line\fP 46 | \fBp-url\fP 47 | \fBp-web\fP 48 | See all 49 | \fBdocumentation\fP 50 | -------------------------------------------------------------------------------- /docs/flush-output.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | flush-output \- (output) 4 | .SH PURPOSE 5 | Flush output. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | flush-output 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | Use flush-output statement to flush any pending output. 19 | 20 | This can be useful if the complete output would take longer to produce and intermittent partial output would be needed. 21 | 22 | .SH EXAMPLES 23 | In this case the complete output may take at least 20 seconds. With flush-output, the message "This is partial output" will be flushed out immediately. 24 | 25 | .RS 4 26 | .EX 27 | 28 | @This is partial output 29 | flush-output 30 | sleep(20); 31 | @This is final output 32 | 33 | .EE 34 | .RE 35 | 36 | .SH SEE ALSO 37 | Output 38 | 39 | \fBfinish-output\fP 40 | \fBflush-output\fP 41 | \fBoutput-statement\fP 42 | \fBpf-out\fP 43 | \fBpf-url\fP 44 | \fBpf-web\fP 45 | \fBp-num\fP 46 | \fBp-out\fP 47 | \fBp-path\fP 48 | \fBp-source-file\fP 49 | \fBp-source-line\fP 50 | \fBp-url\fP 51 | \fBp-web\fP 52 | See all 53 | \fBdocumentation\fP 54 | -------------------------------------------------------------------------------- /docs/get-cookie.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | get-cookie \- (cookies) 4 | .SH PURPOSE 5 | Get cookie value. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | get-cookie ( = ) ,... 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | get-cookie obtains string of a cookie with the name given by string . A cookie would be obtained via incoming request from the client (such as web browser) or it would be set using \fBset-cookie\fP. 19 | 20 | The value of cookie is stored in . 21 | 22 | Cookies are often used to persist user data on the client, such as for maintaining session security or for convenience of identifying the user etc. 23 | 24 | You can obtain multiple cookies separated by a comma: 25 | 26 | .RS 4 27 | .EX 28 | 29 | get-cookie c = "mycookie", c1 = "mycookie1", c2="mycookie2" 30 | 31 | .EE 32 | .RE 33 | 34 | 35 | .SH EXAMPLES 36 | Get value of cookie named "my_cookie_name" - variable my_cookie_value will hold its value: 37 | 38 | .RS 4 39 | .EX 40 | 41 | get-cookie my_cookie_value="my_cookie_name" 42 | 43 | .EE 44 | .RE 45 | 46 | .SH SEE ALSO 47 | Cookies 48 | 49 | \fBdelete-cookie\fP 50 | \fBget-cookie\fP 51 | \fBset-cookie\fP 52 | See all 53 | \fBdocumentation\fP 54 | -------------------------------------------------------------------------------- /docs/get-hash.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | get-hash \- (hash) 4 | .SH PURPOSE 5 | Get usage specifics for a hash. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | get-hash \\ 13 | ( length ) \\ 14 | | ( hash-size ) \\ 15 | | ( average-reads ) 16 | 17 | .EE 18 | .RE 19 | 20 | .SH DESCRIPTION 21 | get-hash provides usage specifics of a (created by \fBnew-hash\fP). 22 | 23 | Use "length" clause to obtain its (i.e. the number of elements stored in it), "hash-size" clause to obtain its (i.e. the number of "buckets", or possible hash codes in the underlying hash table). 24 | 25 | "average-reads" clause will obtain in the average number of reads (i.e. how many string comparisons are needed on average to find a key) multiplied by 100 (so if an average number of reads was 1.5, it will be 150). 26 | 27 | This information may be useful in determining the performance of a hash, and whether \fBresize-hash\fP is indicated. 28 | 29 | .SH EXAMPLES 30 | 31 | .RS 4 32 | .EX 33 | 34 | get-hash h length l hash-size s average-reads r 35 | 36 | .EE 37 | .RE 38 | 39 | .SH SEE ALSO 40 | Hash 41 | 42 | \fBget-hash\fP 43 | \fBnew-hash\fP 44 | \fBpurge-hash\fP 45 | \fBread-hash\fP 46 | \fBresize-hash\fP 47 | \fBwrite-hash\fP 48 | See all 49 | \fBdocumentation\fP 50 | -------------------------------------------------------------------------------- /docs/get-list.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | get-list \- (linked-list) 4 | .SH PURPOSE 5 | Get information about linked list. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | get-list count 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | get-list will obtain information about linked created with \fBnew-list\fP. 19 | 20 | (in "count" clause) is the number of elements in the list. 21 | 22 | .SH EXAMPLES 23 | Get the number of elements in list "mylist" in number "size": 24 | 25 | .RS 4 26 | .EX 27 | 28 | get-list mylist count size 29 | 30 | .EE 31 | .RE 32 | 33 | .SH SEE ALSO 34 | Linked list 35 | 36 | \fBdelete-list\fP 37 | \fBget-list\fP 38 | \fBnew-list\fP 39 | \fBposition-list\fP 40 | \fBpurge-list\fP 41 | \fBread-list\fP 42 | \fBwrite-list\fP 43 | See all 44 | \fBdocumentation\fP 45 | -------------------------------------------------------------------------------- /docs/get-message.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | get-message \- (messages) 4 | .SH PURPOSE 5 | Get string produced by writing a message. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | get-message to 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | get-message will create a from which must have been created with \fBnew-message\fP. can then be used elsewhere, for instance sent with a remote call (see \fBrun-remote\fP), written to a file etc. 19 | 20 | Once get-message is called, is initialized as if it was just created with \fBnew-message\fP without the "from" clause. 21 | 22 | .SH EXAMPLES 23 | 24 | .RS 4 25 | .EX 26 | 27 | // Create a message 28 | new-message msg 29 | // Write data 30 | write-message msg key "key1" value "value1" 31 | // Get string from message 32 | get-message msg to str 33 | \[char46].. 34 | // Create a new message from string 35 | new-message new from str 36 | // Read data 37 | read-message new key k value v 38 | // Display data 39 | pf-out "[%s] [%s]\en", k,v 40 | 41 | .EE 42 | .RE 43 | 44 | The result is: 45 | 46 | .RS 4 47 | .EX 48 | 49 | [key1] [value1] 50 | 51 | .EE 52 | .RE 53 | 54 | .SH SEE ALSO 55 | Messages 56 | 57 | \fBget-message\fP 58 | \fBnew-message\fP 59 | \fBread-message\fP 60 | \fBSEMI\fP 61 | \fBwrite-message\fP 62 | See all 63 | \fBdocumentation\fP 64 | -------------------------------------------------------------------------------- /docs/get-sys.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | get-sys \- (system-information) 4 | .SH PURPOSE 5 | Obtain data that describes the system. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | get-sys \\ 13 | environment \\ 14 | directory | os-name | os-version \\ 15 | to 16 | 17 | .EE 18 | .RE 19 | 20 | .SH DESCRIPTION 21 | System-describing variables can be obtained with get-sys statement and the result stored into . The following system variables can be obtained: 22 | 23 | .RS 4 24 | \[bu] 25 | "environment" returns the name of a given environment variable . If this is a server program, then the environment passed from a remote caller (such as web proxy) is queried. If this is a \fBcommand-line\fP program, then the environment from the Operating System is queried. In the following example,the QUERY_STRING variable (i.e. the actual query string from URL) is obtained: 26 | 27 | .RS 4 28 | .EX 29 | 30 | get-sys environment "QUERY_STRING" to qstr 31 | 32 | .EE 33 | .RE 34 | 35 | 36 | 37 | .RE 38 | 39 | .RS 4 40 | \[bu] 41 | "directory" is the execution directory of the \fBcommand-line\fP program, i.e. the current working directory when the program was executed. Note that Golf will change the current working directory immediately afterwards to the application home directory (see \fBdirectories\fP). You can use this clause to work with files in the directory where the program was started. If your program runs as a \fBservice\fP, then "directory" clause always returns application home directory, regardless of which directory \fBmgrg\fP program manager started your application from. 42 | 43 | 44 | .RE 45 | 46 | .RS 4 47 | \[bu] 48 | "os-name" is the name of Operating System. 49 | 50 | 51 | .RE 52 | 53 | .RS 4 54 | \[bu] 55 | "os-version" is the version of Operating System. 56 | .RE 57 | 58 | 59 | .SH EXAMPLES 60 | Get the name of the Operating System 61 | 62 | .RS 4 63 | .EX 64 | 65 | get-sys os-name to os_name 66 | 67 | .EE 68 | .RE 69 | 70 | .SH SEE ALSO 71 | System information 72 | 73 | \fBget-sys\fP 74 | See all 75 | \fBdocumentation\fP 76 | -------------------------------------------------------------------------------- /docs/get-tree.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | get-tree \- (tree) 4 | .SH PURPOSE 5 | Get information about a tree. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | get-tree \\ 13 | ( count ) | ( hops ) 14 | 15 | .EE 16 | .RE 17 | 18 | .SH DESCRIPTION 19 | get-tree provides information about (created by \fBnew-tree\fP): 20 | 21 | .RS 4 22 | \[bu] 23 | (in "count" clause) provides the number of keys (i.e. nodes) in the tree. 24 | 25 | .RE 26 | 27 | .RS 4 28 | \[bu] 29 | (in "hops" clause) provides the number of nodes accessed to find a key in the last tree statement executed prior to get-tree. Note that is available only in debug Golf build (see \fBinstalling from source\fP); otherwise it is always zero. 30 | 31 | .SH EXAMPLES 32 | Get the number of nodes (keys) in a tree: 33 | 34 | .RS 4 35 | .EX 36 | 37 | new-tree mytree 38 | \[char46].. 39 | get-tree mytree count c 40 | 41 | .EE 42 | .RE 43 | 44 | .SH SEE ALSO 45 | Tree 46 | 47 | \fBdelete-tree\fP 48 | \fBget-tree\fP 49 | \fBnew-tree\fP 50 | \fBpurge-tree\fP 51 | \fBread-tree\fP 52 | \fBuse-cursor\fP 53 | \fBwrite-tree\fP 54 | See all 55 | \fBdocumentation\fP 56 | -------------------------------------------------------------------------------- /docs/handler-status.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | handler-status \- (program-execution) 4 | .SH PURPOSE 5 | Set handler return status. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | handler-status 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | handler-status specifies , which must be a number. 19 | 20 | can be obtained with "handler-status" clause in \fBread-remote\fP in the service caller. 21 | 22 | When the program runs as \fBcommand-line\fP, is program's exit code. 23 | 24 | handler-status can be specified anywhere in the code, and does not mean exiting the \fBrequest\fP's processing; to do that, either use \fBexit-handler\fP or simply allow the handler to reach its end. 25 | 26 | When handler-status is not used, the default exit code is 0. When multiple handler-status statements run in a sequence, the request status is that of the last one that executes. 27 | 28 | If you want to specify request status and exit request processing at the same time, use \fBexit-handler\fP. 29 | 30 | .SH EXAMPLES 31 | When the program exits, its exit code will be 12: 32 | 33 | .RS 4 34 | .EX 35 | 36 | handler-status 12 37 | \[char46].. 38 | exit-handler 39 | 40 | .EE 41 | .RE 42 | 43 | .SH SEE ALSO 44 | Program execution 45 | 46 | \fBexec-program\fP 47 | \fBhandler-status\fP 48 | See all 49 | \fBdocumentation\fP 50 | -------------------------------------------------------------------------------- /docs/hash-string.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | hash-string \- (encryption) 4 | .SH PURPOSE 5 | Hash a string. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | hash-string to \\ 13 | [ binary [ ] \\ 14 | [ digest ] 15 | 16 | .EE 17 | .RE 18 | 19 | .SH DESCRIPTION 20 | hash-string produces by default a SHA256 hash of (if "digest" clause is not used), and stores the result into . You can use a different in "digest" clause (for example "SHA3-256"). To see a list of available digests: 21 | 22 | .RS 4 23 | .EX 24 | 25 | \[char35]get digests 26 | openssl list -digest-algorithms 27 | 28 | .EE 29 | .RE 30 | 31 | If "binary" clause is used without boolean variable , or if evaluates to true, then the is a binary string that may contain null-characters. With the default SHA256, it is 32 bytes in length, while for instance with SHA3-384 it is 48 bytes in length, etc. 32 | 33 | Without "binary" clause, or if evaluates to false, each binary byte of hashed string is converted to two hexadecimal characters ("0"-"9" and "a"-"f"), hence is twice as long as with "binary" clause. 34 | 35 | .SH EXAMPLES 36 | String "result" will have a hashed value of the given string, an example of which might look like "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855": 37 | 38 | .RS 4 39 | .EX 40 | 41 | hash-string "hello world" to hash 42 | 43 | .EE 44 | .RE 45 | 46 | Using a different digest: 47 | 48 | .RS 4 49 | .EX 50 | 51 | hash-string "hello world" to hash digest "sha3-384" 52 | 53 | .EE 54 | .RE 55 | 56 | Producing a binary value instead of a null-terminated hexadecimal string: 57 | 58 | .RS 4 59 | .EX 60 | 61 | hash-string "hello world" to hash digest "sha3-384" binary 62 | 63 | .EE 64 | .RE 65 | 66 | .SH SEE ALSO 67 | Encryption 68 | 69 | \fBdecrypt-data\fP 70 | \fBderive-key\fP 71 | \fBencrypt-data\fP 72 | \fBhash-string\fP 73 | \fBhmac-string\fP 74 | \fBrandom-crypto\fP 75 | \fBrandom-string\fP 76 | See all 77 | \fBdocumentation\fP 78 | -------------------------------------------------------------------------------- /docs/hmac-string.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | hmac-string \- (encryption) 4 | .SH PURPOSE 5 | Create HMAC. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | hmac-string to \\ 13 | key \\ 14 | [ binary [ ] \\ 15 | [ digest ] 16 | 17 | .EE 18 | .RE 19 | 20 | .SH DESCRIPTION 21 | hmac-string produces by default a SHA256-based HMAC (Hash Message Authentication Code) of (if "digest" clause is not used) using secret , and stores the result into . You can use a different in "digest" clause (for example "SHA3-256"). To see a list of available digests: 22 | 23 | .RS 4 24 | .EX 25 | 26 | \[char35]get digests 27 | openssl list -digest-algorithms 28 | 29 | .EE 30 | .RE 31 | 32 | If "binary" clause is used without boolean variable , or if evaluates to true, then the is a binary string that may contain null-characters. With the default SHA256, it is 32 bytes in length, while for instance with SHA3-384 it is 48 bytes in length, etc. 33 | 34 | Without "binary" clause, or if evaluates to false, each binary byte of HMAC is converted to two hexadecimal characters ("0"-"9" and "a"-"f"), hence is twice as long as with "binary" clause. 35 | 36 | .SH EXAMPLES 37 | String "result" will have a HMAC value of a given string, an example of which might look like "2d948cc89148ef96fa4f1876e74af4ce984423d355beb12f7fdba5383143bee0" 38 | 39 | .RS 4 40 | .EX 41 | 42 | hmac-string "some data" key "mykey" to result 43 | 44 | .EE 45 | .RE 46 | 47 | Using a different digest: 48 | 49 | .RS 4 50 | .EX 51 | 52 | hmac-string "some data" key "mykey" to result digest "sha3-384" 53 | 54 | .EE 55 | .RE 56 | 57 | Producing a binary value instead of a null-terminated hexadecimal string, and then making a Base64 string out of it: 58 | 59 | .RS 4 60 | .EX 61 | 62 | hmac-string "some data" key "mykey" digest "SHA256" to result binary 63 | encode-base64 result to bresult 64 | 65 | .EE 66 | .RE 67 | 68 | .SH SEE ALSO 69 | Encryption 70 | 71 | \fBdecrypt-data\fP 72 | \fBderive-key\fP 73 | \fBencrypt-data\fP 74 | \fBhash-string\fP 75 | \fBhmac-string\fP 76 | \fBrandom-crypto\fP 77 | \fBrandom-string\fP 78 | See all 79 | \fBdocumentation\fP 80 | -------------------------------------------------------------------------------- /docs/if-defined.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | if-defined \- (program-flow) 4 | .SH PURPOSE 5 | Conditional compilation. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | if-defined 13 | 14 | end-defined 15 | 16 | if-not-defined 17 | 18 | end-defined 19 | 20 | .EE 21 | .RE 22 | 23 | .SH DESCRIPTION 24 | if-defined will cause to be compiled if is defined (see "--cflag" option in gg). If is not defined, then is not compiled at all. 25 | 26 | if-not-defined will cause to be compiled if is not defined (see "--cflag" option in gg). If is defined, then is compiled. 27 | 28 | .SH EXAMPLES 29 | The following code will have a different output depending on how is application compiled: 30 | 31 | .RS 4 32 | .EX 33 | 34 | if-defined DEF1 35 | @Defined 36 | end-defined 37 | if-not-defined DEF1 38 | @Not defined 39 | end-defined 40 | 41 | .EE 42 | .RE 43 | 44 | If compiled with: 45 | 46 | .RS 4 47 | .EX 48 | 49 | gg -q 50 | 51 | .EE 52 | .RE 53 | 54 | then the output is: 55 | 56 | .RS 4 57 | .EX 58 | 59 | Not defined 60 | 61 | .EE 62 | .RE 63 | 64 | If compiled with: 65 | 66 | .RS 4 67 | .EX 68 | 69 | gg -q --cflag="-DDEF1" 70 | 71 | .EE 72 | .RE 73 | 74 | then the output is: 75 | 76 | .RS 4 77 | .EX 78 | 79 | Defined 80 | 81 | .EE 82 | .RE 83 | 84 | .SH SEE ALSO 85 | Program flow 86 | 87 | \fBbreak-loop\fP 88 | \fBcode-blocks\fP 89 | \fBcontinue-loop\fP 90 | \fBdo-once\fP 91 | \fBexit-handler\fP 92 | \fBif-defined\fP 93 | \fBif-true\fP 94 | \fBreturn-handler\fP 95 | \fBset-bool\fP 96 | \fBstart-loop\fP 97 | See all 98 | \fBdocumentation\fP 99 | -------------------------------------------------------------------------------- /docs/inline-code.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | inline-code \- (language) 4 | .SH PURPOSE 5 | Inline Golf code in an output statement. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | <> 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | You can write Golf statements within an \fBoutput-statement\fP by using them between << and >> delimiters. 19 | 20 | The following statements can be inlined: \fBp-path\fP,\fBp-out\fP, \fBp-web\fP, \fBp-url\fP, \fBpf-out\fP, \fBpf-web\fP, \fBpf-url\fP, \fBp-num\fP, \fBcurrent-row\fP, \fBnumber-string\fP, \fBstring-length\fP, \fBcall-handler\fP. 21 | 22 | .SH EXAMPLES 23 | \fBp-out\fP statement displays a string, and in the following code it's used to display a result within an \fBoutput-statement\fP (i.e. within "@" statement): 24 | 25 | .RS 4 26 | .EX 27 | 28 | run-query ="select firstName, lastName from people" output firstName, lastName 29 | @ 30 | @ 31 | @ First name is <> 32 | @ 33 | @ 34 | @ Last name is <> 35 | @ 36 | @ 37 | end-query 38 | 39 | .EE 40 | .RE 41 | 42 | In the code below, "some_req" is a request handler that outputs some text, and it's used inline to output "Hello world": 43 | 44 | .RS 4 45 | .EX 46 | 47 | @Hello <> 48 | 49 | .EE 50 | .RE 51 | 52 | \fBcall-handler\fP "some-req" would simply output "world": 53 | 54 | .RS 4 55 | .EX 56 | 57 | %% /some-req public 58 | @world 59 | %% 60 | 61 | .EE 62 | .RE 63 | 64 | A \fBwrite-string\fP is typically used with output statements; in this case we print the value of another string, resulting in "There is 42 minutes left!": 65 | 66 | .RS 4 67 | .EX 68 | 69 | set-string mins="42" 70 | (( my_string 71 | @There is <> minutes left! 72 | )) 73 | 74 | .EE 75 | .RE 76 | 77 | .SH SEE ALSO 78 | Language 79 | 80 | \fBinline-code\fP 81 | \fBstatements\fP 82 | \fBsyntax-highlighting\fP 83 | \fBunused-var\fP 84 | \fBvariable-scope\fP 85 | See all 86 | \fBdocumentation\fP 87 | -------------------------------------------------------------------------------- /docs/install-arch-manjaro.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | install-arch-manjaro \- Golf documentation (install-golf) 4 | .SH DESCRIPTION 5 | 6 | .LP 7 | .B INSTALL GOLF ON ARCH AND MANJARO: 8 | .LP 9 | 10 | Run this one time to add Golf key: 11 | 12 | .RS 4 13 | .EX 14 | 15 | echo -e "[home_golf_lang_Arch]\enServer = https://download.opensuse.org/repositories/home:/golf_lang/Arch/x86_64" | sudo tee -a /etc/pacman.conf 16 | key=$(curl -fsSL https://download.opensuse.org/repositories/home:golf_lang/Arch/$(uname -m)/home_golf_lang_Arch.key) 17 | fingerprint=$(echo "${key}"|gpg --quiet --with-colons --import-options show-only --import --fingerprint - | awk -F: '$1 == "fpr" { print $10 }') 18 | sudo pacman-key --init 19 | echo "${key}" | sudo pacman-key --add - 20 | sudo pacman-key --lsign-key "${fingerprint}" 21 | 22 | .EE 23 | .RE 24 | 25 | Install Golf: 26 | 27 | .RS 4 28 | .EX 29 | 30 | sudo pacman --noconfirm -Sy home_golf_lang_Arch/golf 31 | 32 | .EE 33 | .RE 34 | 35 | .SH SEE ALSO 36 | Install golf 37 | 38 | \fBinstall-arch-manjaro\fP 39 | \fBinstall-debian\fP 40 | \fBinstall-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 41 | \fBinstall-from-source-arch-manjaro\fP 42 | \fBinstall-from-source-debian-ubuntu-raspbian\fP 43 | \fBinstall-from-source-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 44 | \fBinstall-from-source-opensuse\fP 45 | \fBinstall-in-any-folder-arch-manjaro\fP 46 | \fBinstall-in-any-folder-debian-ubuntu-raspbian\fP 47 | \fBinstall-in-any-folder-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 48 | \fBinstall-in-any-folder-opensuse\fP 49 | \fBinstall-opensuse\fP 50 | \fBinstall-raspbian\fP 51 | \fBinstall-ubuntu\fP 52 | \fBuninstall\fP 53 | See all 54 | \fBdocumentation\fP 55 | -------------------------------------------------------------------------------- /docs/install-debian.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | install-debian \- Golf documentation (install-golf) 4 | .SH DESCRIPTION 5 | 6 | .LP 7 | .B INSTALL GOLF ON DEBIAN (10, 11, 12, UNSTABLE): 8 | .LP 9 | 10 | Replace 'Debian_12' with 'Debian_10', 'Debian_11' or 'Debian_Unstable' (i.e. 13) to install on Debian 10, 11 or Unstable (the latest upcoming 13): 11 | 12 | .RS 4 13 | .EX 14 | 15 | sudo apt install -y curl gpg 16 | echo 'deb http://download.opensuse.org/repositories/home:/golf_lang/Debian_12/ /' | sudo tee /etc/apt/sources.list.d/home:golf_lang.list 17 | curl -fsSL https://download.opensuse.org/repositories/home:golf_lang/Debian_12/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_golf_lang.gpg > /dev/null 18 | sudo apt update 19 | sudo apt install -y golf 20 | 21 | .EE 22 | .RE 23 | 24 | .SH SEE ALSO 25 | Install golf 26 | 27 | \fBinstall-arch-manjaro\fP 28 | \fBinstall-debian\fP 29 | \fBinstall-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 30 | \fBinstall-from-source-arch-manjaro\fP 31 | \fBinstall-from-source-debian-ubuntu-raspbian\fP 32 | \fBinstall-from-source-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 33 | \fBinstall-from-source-opensuse\fP 34 | \fBinstall-in-any-folder-arch-manjaro\fP 35 | \fBinstall-in-any-folder-debian-ubuntu-raspbian\fP 36 | \fBinstall-in-any-folder-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 37 | \fBinstall-in-any-folder-opensuse\fP 38 | \fBinstall-opensuse\fP 39 | \fBinstall-raspbian\fP 40 | \fBinstall-ubuntu\fP 41 | \fBuninstall\fP 42 | See all 43 | \fBdocumentation\fP 44 | -------------------------------------------------------------------------------- /docs/install-fedora-redhat-rocky-alma-centos-amazon-mageia.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | install-fedora-redhat-rocky-alma-centos-amazon-mageia \- Golf documentation (install-golf) 4 | .SH DESCRIPTION 5 | 6 | .LP 7 | .B INSTALL GOLF ON REDHAT (INCL. ROCKY, ALMA, CENTOS), FEDORA, AMAZON LINUX, MAGEIA 8 | .LP 9 | 10 | 11 | .RS 4 12 | .EX 13 | 14 | sudo dnf -y install epel-release || true 15 | sudo dnf -y copr enable golf-lang/golf-lang 16 | sudo dnf -y install golf 17 | 18 | .EE 19 | .RE 20 | 21 | .SH SEE ALSO 22 | Install golf 23 | 24 | \fBinstall-arch-manjaro\fP 25 | \fBinstall-debian\fP 26 | \fBinstall-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 27 | \fBinstall-from-source-arch-manjaro\fP 28 | \fBinstall-from-source-debian-ubuntu-raspbian\fP 29 | \fBinstall-from-source-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 30 | \fBinstall-from-source-opensuse\fP 31 | \fBinstall-in-any-folder-arch-manjaro\fP 32 | \fBinstall-in-any-folder-debian-ubuntu-raspbian\fP 33 | \fBinstall-in-any-folder-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 34 | \fBinstall-in-any-folder-opensuse\fP 35 | \fBinstall-opensuse\fP 36 | \fBinstall-raspbian\fP 37 | \fBinstall-ubuntu\fP 38 | \fBuninstall\fP 39 | See all 40 | \fBdocumentation\fP 41 | -------------------------------------------------------------------------------- /docs/install-from-source-arch-manjaro.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | install-from-source-arch-manjaro \- Golf documentation (install-golf) 4 | .SH DESCRIPTION 5 | 6 | .LP 7 | .B GET LATEST GOLF SOURCE CODE 8 | .LP 9 | 10 | You must have git installed. Get Golf source code for the latest version: 11 | 12 | .RS 4 13 | .EX 14 | 15 | sudo pacman -Sy --noconfirm wget tar 16 | wget "https://github.com/golf-lang/golf/archive/refs/heads/main.tar.gz" -O main.tar.gz 17 | tar xvfz main.tar.gz 18 | cd golf-main 19 | 20 | .EE 21 | .RE 22 | 23 | 24 | .LP 25 | .B INSTALL DEPENDENCIES 26 | .LP 27 | 28 | 29 | .RS 4 30 | .EX 31 | 32 | sudo pacman -Sy --noconfirm debugedit 33 | makepkg -s --noconfirm -o 34 | 35 | .EE 36 | .RE 37 | 38 | 39 | .LP 40 | .B BUILD GOLF 41 | .LP 42 | 43 | 44 | .RS 4 45 | .EX 46 | 47 | make clean 48 | make 49 | sudo make install 50 | 51 | .EE 52 | .RE 53 | 54 | Here's how to \fBuninstall\fP. 55 | .SH SEE ALSO 56 | Install golf 57 | 58 | \fBinstall-arch-manjaro\fP 59 | \fBinstall-debian\fP 60 | \fBinstall-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 61 | \fBinstall-from-source-arch-manjaro\fP 62 | \fBinstall-from-source-debian-ubuntu-raspbian\fP 63 | \fBinstall-from-source-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 64 | \fBinstall-from-source-opensuse\fP 65 | \fBinstall-in-any-folder-arch-manjaro\fP 66 | \fBinstall-in-any-folder-debian-ubuntu-raspbian\fP 67 | \fBinstall-in-any-folder-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 68 | \fBinstall-in-any-folder-opensuse\fP 69 | \fBinstall-opensuse\fP 70 | \fBinstall-raspbian\fP 71 | \fBinstall-ubuntu\fP 72 | \fBuninstall\fP 73 | See all 74 | \fBdocumentation\fP 75 | -------------------------------------------------------------------------------- /docs/install-from-source-debian-ubuntu-raspbian.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | install-from-source-debian-ubuntu-raspbian \- Golf documentation (install-golf) 4 | .SH DESCRIPTION 5 | 6 | .LP 7 | .B GET LATEST GOLF SOURCE CODE 8 | .LP 9 | 10 | Get Golf source code for the latest version: 11 | 12 | .RS 4 13 | .EX 14 | 15 | sudo apt update 16 | sudo apt -y install wget tar 17 | wget "https://github.com/golf-lang/golf/archive/refs/heads/main.tar.gz" -O main.tar.gz 18 | tar xvfz main.tar.gz 19 | cd golf-main 20 | 21 | .EE 22 | .RE 23 | 24 | 25 | .LP 26 | .B INSTALL DEPENDENCIES 27 | .LP 28 | 29 | 30 | .RS 4 31 | .EX 32 | 33 | sudo apt update 34 | sudo apt -y install devscripts equivs build-essential 35 | yes|mk-build-deps -i -s sudo debian-upstream/control 36 | 37 | .EE 38 | .RE 39 | 40 | 41 | .LP 42 | .B BUILD GOLF 43 | .LP 44 | 45 | 46 | .RS 4 47 | .EX 48 | 49 | make clean 50 | make 51 | sudo make install 52 | 53 | .EE 54 | .RE 55 | 56 | Here's how to \fBuninstall\fP. 57 | .SH SEE ALSO 58 | Install golf 59 | 60 | \fBinstall-arch-manjaro\fP 61 | \fBinstall-debian\fP 62 | \fBinstall-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 63 | \fBinstall-from-source-arch-manjaro\fP 64 | \fBinstall-from-source-debian-ubuntu-raspbian\fP 65 | \fBinstall-from-source-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 66 | \fBinstall-from-source-opensuse\fP 67 | \fBinstall-in-any-folder-arch-manjaro\fP 68 | \fBinstall-in-any-folder-debian-ubuntu-raspbian\fP 69 | \fBinstall-in-any-folder-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 70 | \fBinstall-in-any-folder-opensuse\fP 71 | \fBinstall-opensuse\fP 72 | \fBinstall-raspbian\fP 73 | \fBinstall-ubuntu\fP 74 | \fBuninstall\fP 75 | See all 76 | \fBdocumentation\fP 77 | -------------------------------------------------------------------------------- /docs/install-from-source-fedora-redhat-rocky-alma-centos-amazon-mageia.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | install-from-source-fedora-redhat-rocky-alma-centos-amazon-mageia \- Golf documentation (install-golf) 4 | .SH DESCRIPTION 5 | 6 | .LP 7 | .B GET LATEST GOLF SOURCE CODE 8 | .LP 9 | 10 | Get Golf source code for the latest version: 11 | 12 | .RS 4 13 | .EX 14 | 15 | sudo dnf -y install wget tar 16 | wget "https://github.com/golf-lang/golf/archive/refs/heads/main.tar.gz" -O main.tar.gz 17 | tar xvfz main.tar.gz 18 | cd golf-main 19 | 20 | .EE 21 | .RE 22 | 23 | 24 | .LP 25 | .B INSTALL DEPENDENCIES 26 | .LP 27 | 28 | 29 | .RS 4 30 | .EX 31 | 32 | sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm || true 33 | sudo dnf install -y rpmdevtools 34 | sudo dnf builddep -y golf.spec 35 | 36 | .EE 37 | .RE 38 | 39 | 40 | .LP 41 | .B BUILD GOLF 42 | .LP 43 | 44 | 45 | .RS 4 46 | .EX 47 | 48 | make clean 49 | make 50 | sudo make install 51 | 52 | .EE 53 | .RE 54 | 55 | Here's how to \fBuninstall\fP. 56 | .SH SEE ALSO 57 | Install golf 58 | 59 | \fBinstall-arch-manjaro\fP 60 | \fBinstall-debian\fP 61 | \fBinstall-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 62 | \fBinstall-from-source-arch-manjaro\fP 63 | \fBinstall-from-source-debian-ubuntu-raspbian\fP 64 | \fBinstall-from-source-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 65 | \fBinstall-from-source-opensuse\fP 66 | \fBinstall-in-any-folder-arch-manjaro\fP 67 | \fBinstall-in-any-folder-debian-ubuntu-raspbian\fP 68 | \fBinstall-in-any-folder-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 69 | \fBinstall-in-any-folder-opensuse\fP 70 | \fBinstall-opensuse\fP 71 | \fBinstall-raspbian\fP 72 | \fBinstall-ubuntu\fP 73 | \fBuninstall\fP 74 | See all 75 | \fBdocumentation\fP 76 | -------------------------------------------------------------------------------- /docs/install-from-source-opensuse.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | install-from-source-opensuse \- Golf documentation (install-golf) 4 | .SH DESCRIPTION 5 | 6 | .LP 7 | .B GET LATEST GOLF SOURCE CODE 8 | .LP 9 | 10 | You must have git installed. Get Golf source code for the latest version: 11 | 12 | .RS 4 13 | .EX 14 | 15 | sudo zypper --non-interactive in wget tar 16 | wget "https://github.com/golf-lang/golf/archive/refs/heads/main.tar.gz" -O main.tar.gz 17 | tar xvfz main.tar.gz 18 | cd golf-main 19 | 20 | .EE 21 | .RE 22 | 23 | 24 | .LP 25 | .B INSTALL DEPENDENCIES 26 | .LP 27 | 28 | 29 | .RS 4 30 | .EX 31 | 32 | sudo zypper --non-interactive in --replacefiles --force-resolution rpm-build 33 | sudo zypper -n install $(rpmspec --parse golf.spec | grep BuildRequires|sed 's/^.*:\e(.*\e)$/\e1/g') 34 | 35 | .EE 36 | .RE 37 | 38 | 39 | .LP 40 | .B BUILD GOLF 41 | .LP 42 | 43 | 44 | .RS 4 45 | .EX 46 | 47 | make clean 48 | make 49 | sudo make install 50 | 51 | .EE 52 | .RE 53 | 54 | Here's how to \fBuninstall\fP. 55 | .SH SEE ALSO 56 | Install golf 57 | 58 | \fBinstall-arch-manjaro\fP 59 | \fBinstall-debian\fP 60 | \fBinstall-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 61 | \fBinstall-from-source-arch-manjaro\fP 62 | \fBinstall-from-source-debian-ubuntu-raspbian\fP 63 | \fBinstall-from-source-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 64 | \fBinstall-from-source-opensuse\fP 65 | \fBinstall-in-any-folder-arch-manjaro\fP 66 | \fBinstall-in-any-folder-debian-ubuntu-raspbian\fP 67 | \fBinstall-in-any-folder-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 68 | \fBinstall-in-any-folder-opensuse\fP 69 | \fBinstall-opensuse\fP 70 | \fBinstall-raspbian\fP 71 | \fBinstall-ubuntu\fP 72 | \fBuninstall\fP 73 | See all 74 | \fBdocumentation\fP 75 | -------------------------------------------------------------------------------- /docs/install-opensuse.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | install-opensuse \- Golf documentation (install-golf) 4 | .SH DESCRIPTION 5 | 6 | .LP 7 | .B INSTALL GOLF ON OPENSUSE: 8 | .LP 9 | 10 | Install OpenSUSE Tumbleweed: 11 | 12 | .RS 4 13 | .EX 14 | 15 | sudo zypper addrepo https://download.opensuse.org/repositories/home:golf_lang/openSUSE_Tumbleweed/home:golf_lang.repo 16 | sudo zypper --gpg-auto-import-keys refresh 17 | sudo zypper -n install --replacefiles --force-resolution golf 18 | 19 | .EE 20 | .RE 21 | 22 | Install OpenSUSE Leap 15.6: 23 | 24 | .RS 4 25 | .EX 26 | 27 | sudo zypper addrepo https://download.opensuse.org/repositories/home:golf_lang/15.6/home:golf_lang.repo 28 | sudo zypper --gpg-auto-import-keys refresh 29 | sudo zypper -n install --replacefiles --force-resolution golf 30 | 31 | .EE 32 | .RE 33 | 34 | Install OpenSUSE Slowroll: 35 | 36 | .RS 4 37 | .EX 38 | 39 | sudo zypper addrepo https://download.opensuse.org/repositories/home:golf_lang/openSUSE_Slowroll/home:golf_lang.repo 40 | sudo zypper --gpg-auto-import-keys refresh 41 | sudo zypper -n install --replacefiles --force-resolution golf 42 | 43 | .EE 44 | .RE 45 | 46 | .SH SEE ALSO 47 | Install golf 48 | 49 | \fBinstall-arch-manjaro\fP 50 | \fBinstall-debian\fP 51 | \fBinstall-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 52 | \fBinstall-from-source-arch-manjaro\fP 53 | \fBinstall-from-source-debian-ubuntu-raspbian\fP 54 | \fBinstall-from-source-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 55 | \fBinstall-from-source-opensuse\fP 56 | \fBinstall-in-any-folder-arch-manjaro\fP 57 | \fBinstall-in-any-folder-debian-ubuntu-raspbian\fP 58 | \fBinstall-in-any-folder-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 59 | \fBinstall-in-any-folder-opensuse\fP 60 | \fBinstall-opensuse\fP 61 | \fBinstall-raspbian\fP 62 | \fBinstall-ubuntu\fP 63 | \fBuninstall\fP 64 | See all 65 | \fBdocumentation\fP 66 | -------------------------------------------------------------------------------- /docs/install-raspbian.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | install-raspbian \- Golf documentation (install-golf) 4 | .SH DESCRIPTION 5 | 6 | .LP 7 | .B INSTALL GOLF ON RASPBIAN (RASPBERRY OS), AARCH64 ONLY: 8 | .LP 9 | 10 | 11 | .RS 4 12 | .EX 13 | 14 | sudo apt install -y curl 15 | echo 'deb http://download.opensuse.org/repositories/home:/golf_lang/Raspbian_12/ /' | sudo tee /etc/apt/sources.list.d/home:golf_lang.list 16 | curl -fsSL https://download.opensuse.org/repositories/home:golf_lang/Raspbian_12/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_golf_lang.gpg > /dev/null 17 | sudo apt update 18 | sudo apt -y install golf 19 | 20 | .EE 21 | .RE 22 | 23 | .SH SEE ALSO 24 | Install golf 25 | 26 | \fBinstall-arch-manjaro\fP 27 | \fBinstall-debian\fP 28 | \fBinstall-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 29 | \fBinstall-from-source-arch-manjaro\fP 30 | \fBinstall-from-source-debian-ubuntu-raspbian\fP 31 | \fBinstall-from-source-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 32 | \fBinstall-from-source-opensuse\fP 33 | \fBinstall-in-any-folder-arch-manjaro\fP 34 | \fBinstall-in-any-folder-debian-ubuntu-raspbian\fP 35 | \fBinstall-in-any-folder-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 36 | \fBinstall-in-any-folder-opensuse\fP 37 | \fBinstall-opensuse\fP 38 | \fBinstall-raspbian\fP 39 | \fBinstall-ubuntu\fP 40 | \fBuninstall\fP 41 | See all 42 | \fBdocumentation\fP 43 | -------------------------------------------------------------------------------- /docs/install-ubuntu.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | install-ubuntu \- Golf documentation (install-golf) 4 | .SH DESCRIPTION 5 | 6 | .LP 7 | .B INSTALL GOLF ON UBUNTU (VERSIONS 20, 22, 24, 25): 8 | .LP 9 | 10 | 11 | .RS 4 12 | .EX 13 | 14 | sudo add-apt-repository ppa:golf-lang/golf -y 15 | sudo apt update 16 | sudo apt -y install golf 17 | 18 | .EE 19 | .RE 20 | 21 | .SH SEE ALSO 22 | Install golf 23 | 24 | \fBinstall-arch-manjaro\fP 25 | \fBinstall-debian\fP 26 | \fBinstall-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 27 | \fBinstall-from-source-arch-manjaro\fP 28 | \fBinstall-from-source-debian-ubuntu-raspbian\fP 29 | \fBinstall-from-source-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 30 | \fBinstall-from-source-opensuse\fP 31 | \fBinstall-in-any-folder-arch-manjaro\fP 32 | \fBinstall-in-any-folder-debian-ubuntu-raspbian\fP 33 | \fBinstall-in-any-folder-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 34 | \fBinstall-in-any-folder-opensuse\fP 35 | \fBinstall-opensuse\fP 36 | \fBinstall-raspbian\fP 37 | \fBinstall-ubuntu\fP 38 | \fBuninstall\fP 39 | See all 40 | \fBdocumentation\fP 41 | -------------------------------------------------------------------------------- /docs/license.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | license \- Golf documentation (license) 4 | .SH DESCRIPTION 5 | 6 | .LP 7 | .B LICENSING AND COPYRIGHT 8 | .LP 9 | 10 | Golf is Free Open Source software licensed under \fBApache License 2\fP. 11 | 12 | Golf is copyright (c) 2019-now Gliim LLC. 13 | 14 | .LP 15 | .B DISCUSSION 16 | .LP 17 | 18 | The following discussion is not legal advice. 19 | 20 | Golf makes use of the following dynamically-linked libraries (with copyright by their respective owners), and only if your application actually uses them: 21 | 22 | .RS 4 23 | \[bu] 24 | \fBLGPL-licensed\fP MariaDB C connector (\fBhttps://mariadb.com/kb/en/mariadb-connector-c/\fP), 25 | 26 | .RE 27 | 28 | .RS 4 29 | \[bu] 30 | \fBPostgres-licensed\fP Postgres C library (\fBhttps://www.postgresql.org/docs/current/libpq.html\fP), 31 | 32 | .RE 33 | 34 | .RS 4 35 | \[bu] 36 | \fBSQLite (public domain)\fP SQLite C library (\fBhttps://www.sqlite.org/docs.html\fP), 37 | 38 | .RE 39 | 40 | .RS 4 41 | \[bu] 42 | \fBCurl-licensed\fP Curl library (\fBhttps://curl.se/\fP), 43 | 44 | .RE 45 | 46 | .RS 4 47 | \[bu] 48 | \fBBSD-licensed\fP PCRE2 (regex) library (\fBhttps://www.pcre.org/\fP), 49 | 50 | .RE 51 | 52 | .RS 4 53 | \[bu] 54 | \fBMIT-licensed\fP libxml2 library (\fBhttps://gitlab.gnome.org/GNOME/libxml2\fP), 55 | 56 | .RE 57 | 58 | .RS 4 59 | \[bu] 60 | \fBOpenSSL-licensed\fP SSL/crypto library (\fBhttps://www.openssl.org/\fP). 61 | 62 | .RE 63 | 64 | .RS 4 65 | \[bu] 66 | \fBOpen Market Licensed\fP FastCGI library (\fBhttps://fastcgi-archives.github.io/FastCGI_Developers_Kit_FastCGI.html\fP). 67 | .RE 68 | 69 | You would install these libraries yourself (they are not distributed with Golf) as dependencies for compiling the source code. Golf does not link to any outside static libraries. 70 | 71 | Golf uses FNV-1a hash function, which is released in the public domain (see \fBwikipedia page\fP) and is not patented (see \fBLandon Noll's\fP web page). 72 | 73 | Golf source code uses \fBSPDX\fP, an open ISO standard for communicating software bill of material information (such as licenses), to improve on open source licensing compliance for companies and communities. 74 | .SH SEE ALSO 75 | License 76 | 77 | \fBlicense\fP 78 | See all 79 | \fBdocumentation\fP 80 | -------------------------------------------------------------------------------- /docs/lower-string.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | lower-string \- (strings) 4 | .SH PURPOSE 5 | Lower-case a string. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | lower-string 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | lower-string converts all 's characters to lower case. 19 | 20 | .SH EXAMPLES 21 | The resulting "str" is "good": 22 | 23 | .RS 4 24 | .EX 25 | 26 | set-string str="GOOD" 27 | lower-string str 28 | 29 | .EE 30 | .RE 31 | 32 | .SH SEE ALSO 33 | Strings 34 | 35 | \fBconcatenate-strings\fP 36 | \fBcopy-string\fP 37 | \fBcount-substring\fP 38 | \fBdelete-string\fP 39 | \fBlower-string\fP 40 | \fBread-split\fP 41 | \fBreplace-string\fP 42 | \fBset-string\fP 43 | \fBsplit-string\fP 44 | \fBstring-length\fP 45 | \fBtrim-string\fP 46 | \fBupper-string\fP 47 | \fBwrite-string\fP 48 | See all 49 | \fBdocumentation\fP 50 | -------------------------------------------------------------------------------- /docs/mariadb-database.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | mariadb-database \- Golf documentation (database) 4 | .SH DESCRIPTION 5 | MariaDB configuration file is written as a MariaDB client options file. 6 | 7 | You can see the parameters available at \fBhttps://mariadb.com/kb/en/configuring-mariadb-connectorc-with-option-files/#options\fP. 8 | 9 | Most of the time, though, you would likely use only a few of those options, as in (for local connection): 10 | 11 | .RS 4 12 | .EX 13 | 14 | [client] 15 | user=myuser 16 | password=mypwd 17 | database=mydb 18 | socket=/run/mysqld/mysqld.sock 19 | 20 | .EE 21 | .RE 22 | 23 | The above file has fields "user" (MariaDB user), "password" (the password for MariaDB user), "database" (the MariaDB database name) and MariaDB communication "socket" location (assuming your database is local to your computer - if the database is across network you would not use sockets!). 24 | 25 | If you use passwordless MariaDB login (such as when the MariaDB user name is the same as your Operating System user name and where unix socket plugin is used for authentication), the password would be empty. 26 | 27 | To get the location of the socket, you might use: 28 | 29 | .RS 4 30 | .EX 31 | 32 | sudo mysql -u root -e "show variables like 'socket'" 33 | 34 | .EE 35 | .RE 36 | 37 | .SH SEE ALSO 38 | Database 39 | 40 | \fBbegin-transaction\fP 41 | \fBcommit-transaction\fP 42 | \fBcurrent-row\fP 43 | \fBdatabase-config-file\fP 44 | \fBdb-error\fP 45 | \fBmariadb-database\fP 46 | \fBpostgresql-database\fP 47 | \fBrollback-transaction\fP 48 | \fBrun-query\fP 49 | \fBsqlite-database\fP 50 | See all 51 | \fBdocumentation\fP 52 | -------------------------------------------------------------------------------- /docs/memory-handling.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | memory-handling \- Golf documentation (memory) 4 | .SH DESCRIPTION 5 | Golf is a memory-safe language. 6 | 7 | Your application cannot access memory outside of valid statement results. Trying to do so will result in your program \fBerroring out\fP. 8 | 9 | Memory allocated by Golf statements is tracked and freed at the end of the request. 10 | 11 | With Golf there is no need to free memory manually. Memory is automatically freed even if it is no longer accessible to the program, thus preventing memory leaks; this is important for stability of long-running processes. 12 | 13 | Some statements (\fBnew-tree\fP, \fBnew-hash\fP, \fBnew-list\fP, \fBnew-array\fP and \fBset-string\fP) have the option of allocating memory that won't get freed at the end of the request and is available to any request served by the same process. This kind of memory is called "process-scoped". A process-scoped string can be manually freed. 14 | 15 | Golf handles memory references and assignments automatically, preventing dangling memory. 16 | 17 | String results of any Golf \fBstatements\fP will always create new memory, unless stated otherwise. 18 | 19 | .LP 20 | .B OPEN FILE DESCRIPTORS 21 | .LP 22 | 23 | Any files opened by \fBopen-file\fP statement are automatically closed by Golf at the end of the request. This enhances stability of long-running server processes because Linux system by default offers only about 1000 open files to a process. A bug can quickly exhaust this pool and cause a malfunction or a crash - Golf prevents this by closing any such open files when the request ends. 24 | .SH SEE ALSO 25 | Memory 26 | 27 | \fBmemory-handling\fP 28 | See all 29 | \fBdocumentation\fP 30 | -------------------------------------------------------------------------------- /docs/new-array.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | new-array \- (array) 4 | .SH PURPOSE 5 | Create array. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | new-array [ max-size ] [ process-scope ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | new-array creates new . An array is an indexed array, with a number as an index, and with a string as an element in the array. 19 | 20 | A Golf array is flexible, which means that it will grow to accommodate your needs. By default, an array allocates room for 256 elements that can grow up to 1,000,000 elements, unless number (in "max-size" clause) is specified in which case it can grow up to elements. must be at least 256. 21 | 22 | Note that max-size specifies only the upper limit of allocation. The actual amount of memory allocated can vary greatly, and is only 256 elements for a new array. 23 | 24 | With a Golf array, you do not need to pre-size the array; rather when you write an element, it will resize automatically. For instance, you can set an array element arr[0] and then arr[1000] (with nothing in-between), and Golf will automatically extend the array to accommodate. Note that an array will not automatically contract when tailing elements are deleted. Use \fBpurge-array\fP to delete all elements in the array and shrink its memory footprint when your processing is done. 25 | 26 | .LP 27 | .B SCOPE 28 | .LP 29 | 30 | Note that an array is accessible to the current request only, unless "process-scope" clause is used, in which case all requests served by a process can use it (see \fBdo-once\fP for a typical way to do this). 31 | 32 | If "process-scope" is used, then will keep its data across all requests in a given process. See \fBwrite-array\fP for an example of a process-scoped array. 33 | 34 | .SH EXAMPLES 35 | Create a new array: 36 | 37 | .RS 4 38 | .EX 39 | 40 | new-array arr 41 | 42 | .EE 43 | .RE 44 | 45 | .SH SEE ALSO 46 | Array 47 | 48 | \fBnew-array\fP 49 | \fBpurge-array\fP 50 | \fBread-array\fP 51 | \fBwrite-array\fP 52 | See all 53 | \fBdocumentation\fP 54 | -------------------------------------------------------------------------------- /docs/new-dir.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | new-dir \- (directories) 4 | .SH PURPOSE 5 | Create new directory. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | new-dir [ mode ] [ status ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | new-dir creates new , which is a string that is an absolute or relative path. You can specify permission (in "mode" clause) as a number, based on standard Linux permissions (see \fBpermissions\fP). 19 | 20 | If "status" clauses is used, is a number with value of GG_OKAY if successful, GG_ERR_EXIST if directory exists, or GG_ERR_FAILED for other errors (in which case you can use "errno" clause in \fBget-req\fP to find the specific reason why). 21 | 22 | .SH EXAMPLES 23 | 24 | .RS 4 25 | .EX 26 | 27 | new-dir "new_dir" 28 | 29 | .EE 30 | .RE 31 | 32 | .SH SEE ALSO 33 | Directories 34 | 35 | \fBchange-dir\fP 36 | \fBchange-mode\fP 37 | \fBdelete-dir\fP 38 | \fBdirectories\fP 39 | \fBnew-dir\fP 40 | See all 41 | \fBdocumentation\fP 42 | -------------------------------------------------------------------------------- /docs/new-fifo.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | new-fifo \- (FIFO) 4 | .SH PURPOSE 5 | Create FIFO list. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | new-fifo 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | new-fifo initializes new FIFO (First In First Out). 19 | 20 | contains data stored on a first-in, first out basis. Note that a list is accessible to the current process only. 21 | 22 | Information is retrieved (possibly many times, see \fBrewind-fifo\fP) in the same order in which it was stored. 23 | 24 | The internal positions for \fBwrite-fifo\fP and \fBread-fifo\fP actions are separate so you can keep writing data to the list, and read it independently of writes in any number of retrieval passes by using \fBrewind-fifo\fP. 25 | 26 | .SH EXAMPLES 27 | 28 | .RS 4 29 | .EX 30 | 31 | new-fifo nf 32 | 33 | .EE 34 | .RE 35 | 36 | .SH SEE ALSO 37 | FIFO 38 | 39 | \fBdelete-fifo\fP 40 | \fBnew-fifo\fP 41 | \fBpurge-fifo\fP 42 | \fBread-fifo\fP 43 | \fBrewind-fifo\fP 44 | \fBwrite-fifo\fP 45 | See all 46 | \fBdocumentation\fP 47 | -------------------------------------------------------------------------------- /docs/new-hash.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | new-hash \- (hash) 4 | .SH PURPOSE 5 | Create hash. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | new-hash \\ 13 | [ process-scope ] \\ 14 | [ hash-size ] 15 | 16 | .EE 17 | .RE 18 | 19 | .SH DESCRIPTION 20 | new-hash creates new . A hash is a collection of key/value pairs, called "elements". A value of an element is obtained based on its key value. 21 | 22 | .LP 23 | .B SCOPE 24 | .LP 25 | 26 | Note that a hash is accessible to the current request only, unless "process-scope" clause is used, in which case all requests served by a process can use it (see \fBdo-once\fP for a typical way to create a hash with a process scope). 27 | 28 | If "process-scope" is used, then will keep its data across all requests in a given process. See \fBwrite-hash\fP for an example of a process-scoped hash. 29 | 30 | .LP 31 | .B SIZING A HASH 32 | .LP 33 | 34 | A hash can be of any size, as long as there is enough memory for it. The "hash-size" refers to the size of a hash table used to provide high-performance access to its elements based on a key. 35 | 36 | is the number of "buckets" used by the hash (it is 10 by default). All hash elements with the same hash code are stored in a linked list within the same bucket. Greater generally means less elements per bucket and better performance. However, memory usage grows with a bigger hash table, so should be balanced based on the program needs. 37 | 38 | Golf uses high-performing \fBFNV1_a\fP hash algorithm. Each element in a bucket list is lightweight, containing pointers to a key, value and next element in the linked list. 39 | 40 | must be at least 256; if less, it will be set to 256. 41 | 42 | .SH EXAMPLES 43 | Create a new hash with 5000 buckets: 44 | 45 | .RS 4 46 | .EX 47 | 48 | new-hash h hash-size 5000 49 | 50 | .EE 51 | .RE 52 | 53 | See \fBread-hash\fP for more examples. 54 | .SH SEE ALSO 55 | Hash 56 | 57 | \fBget-hash\fP 58 | \fBnew-hash\fP 59 | \fBpurge-hash\fP 60 | \fBread-hash\fP 61 | \fBresize-hash\fP 62 | \fBwrite-hash\fP 63 | See all 64 | \fBdocumentation\fP 65 | -------------------------------------------------------------------------------- /docs/new-lifo.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | new-lifo \- (LIFO) 4 | .SH PURPOSE 5 | Create LIFO list. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | new-lifo 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | new-lifo initializes new LIFO (Last In First Out). 19 | 20 | contains data stored on a last-in, first-out basis. Note that a list is accessible to the current process only. 21 | 22 | Information is retrieved (possibly many times, see \fBrewind-lifo\fP) in the opposite order in which it was stored. 23 | 24 | .SH EXAMPLES 25 | 26 | .RS 4 27 | .EX 28 | 29 | new-lifo mylifo 30 | 31 | .EE 32 | .RE 33 | 34 | .SH SEE ALSO 35 | LIFO 36 | 37 | \fBdelete-lifo\fP 38 | \fBnew-lifo\fP 39 | \fBpurge-lifo\fP 40 | \fBread-lifo\fP 41 | \fBrewind-lifo\fP 42 | \fBwrite-lifo\fP 43 | See all 44 | \fBdocumentation\fP 45 | -------------------------------------------------------------------------------- /docs/new-list.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | new-list \- (linked-list) 4 | .SH PURPOSE 5 | Create linked list. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | new-list [ process-scope ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | new-list initializes new linked , where each element is connected to the previous and next ones. 19 | 20 | In a linked data that can be added anywhere in the list, and also accessed anywhere as well. Access to a list is sequential, meaning you can position to the first, last, next or previous element. Note that a list is accessible to the current process only. 21 | 22 | Generally information is stored in a linked list, and retrieved (possibly many times) in any order later. 23 | 24 | A list has a current position where an element can be read, updated, inserted or deleted (via \fBread-list\fP, \fBwrite-list\fP and \fBdelete-list\fP), and this position can be explicitly changed with \fBposition-list\fP. 25 | 26 | .LP 27 | .B SCOPE 28 | .LP 29 | 30 | A linked list is accessible to the current process only, unless "process-scope" clause is used, in which case all requests served by the process can use it (see \fBdo-once\fP for a typical way to create an object with a process scope). If "process-scope" is used, then elements of the list will keep their value between requests in the same process. 31 | 32 | See \fBwrite-list\fP for an example of a process-scoped list. 33 | 34 | .SH EXAMPLES 35 | 36 | .RS 4 37 | .EX 38 | 39 | new-list mylist 40 | 41 | .EE 42 | .RE 43 | 44 | .SH SEE ALSO 45 | Linked list 46 | 47 | \fBdelete-list\fP 48 | \fBget-list\fP 49 | \fBnew-list\fP 50 | \fBposition-list\fP 51 | \fBpurge-list\fP 52 | \fBread-list\fP 53 | \fBwrite-list\fP 54 | See all 55 | \fBdocumentation\fP 56 | -------------------------------------------------------------------------------- /docs/new-message.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | new-message \- (messages) 4 | .SH PURPOSE 5 | Create new message. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | new-message [ from ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | new-message will create a new object. 19 | 20 | If is specified (in "from" clause), then it is used to create a from it. The must be in \fBSEMI\fP format, which may be in request's input, from \fBget-message\fP, from reading a file etc; in this case can only be read from with \fBread-message\fP. 21 | 22 | If new-message is used without "from" clause, data can be added to with \fBwrite-message\fP. 23 | 24 | .SH EXAMPLES 25 | 26 | .RS 4 27 | .EX 28 | 29 | begin-handler /msg public 30 | new-message msg 31 | write-message msg key "weather" value "nice" 32 | write-message msg key "distance" value "near" 33 | start-loop 34 | read-message msg key k value v status s 35 | if-true s not-equal GG_OKAY 36 | break-loop 37 | end-if 38 | @Key is <> and value is <> 39 | end-loop 40 | end-handler 41 | 42 | .EE 43 | .RE 44 | 45 | .SH SEE ALSO 46 | Messages 47 | 48 | \fBget-message\fP 49 | \fBnew-message\fP 50 | \fBread-message\fP 51 | \fBSEMI\fP 52 | \fBwrite-message\fP 53 | See all 54 | \fBdocumentation\fP 55 | -------------------------------------------------------------------------------- /docs/number-expressions.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | number-expressions \- Golf documentation (numbers) 4 | .SH DESCRIPTION 5 | A number expression uses operators plus (+), minus (-), multiply (*), divide (/) and modulus (%), as well as parenthesis (). For example: 6 | 7 | .RS 4 8 | .EX 9 | 10 | set-number n1 = 10+(4*n2-5)%3 11 | 12 | .EE 13 | .RE 14 | 15 | You can use number expressions anywhere number is expected as an input to any statement. 16 | 17 | Note that character constants (such as 'A', 'z' etc.) are considered numbers with the value equal to their single-byte ASCII equivalent (i.e. unsigned numbers 0-255), for example this will assign 65 to "num": 18 | 19 | .RS 4 20 | .EX 21 | 22 | set-number num = 'A' 23 | 24 | .EE 25 | .RE 26 | 27 | Any subscripted string is also considered a number, for instance "num" would be 117 (since 's' is 115): 28 | 29 | .RS 4 30 | .EX 31 | 32 | set-string str = 'some' 33 | set-number num = str[0] + 2 34 | 35 | .EE 36 | .RE 37 | 38 | Other than decimals and character constants, you can also use hexadecimal numbers (such as 0xffaa), and octal numbers (such as 0710). 39 | .SH SEE ALSO 40 | Numbers 41 | 42 | \fBnumber-expressions\fP 43 | \fBnumber-string\fP 44 | \fBset-number\fP 45 | \fBstring-number\fP 46 | See all 47 | \fBdocumentation\fP 48 | -------------------------------------------------------------------------------- /docs/number-string.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | number-string \- (numbers) 4 | .SH PURPOSE 5 | Convert number to string. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | number-string [ to ] \\ 13 | [ base ] \\ 14 | [ status ] 15 | 16 | .EE 17 | .RE 18 | 19 | .SH DESCRIPTION 20 | is converted to in "to" clause, using in "base" clause, where is by default 10. can be between 2 and 36, inclusive. can be positive or negative (i.e. signed) and can be of any integer type up to 64-bit (char, int, long, long long etc.). If "to" clause is omitted, then is printed out. 21 | 22 | Note that any letters in (depending on the ) are always lower-case. 23 | 24 | If there is an error, such as if is incorrect, then number (in "status" clause) is GG_ERR_FAILED, otherwise it's GG_OKAY. 25 | 26 | Use of number-string (and \fBp-num\fP which is based on it) for converting and outputting numbers is high-performance and recommended if your application needs to do that often. If number-string prints out a number (i.e. "to" clause is omitted), and this is within \fBwrite-string\fP, then is output into the buffer that builds a new string. 27 | 28 | .SH EXAMPLES 29 | The following will allocate memory for string "x" to be "801": 30 | 31 | .RS 4 32 | .EX 33 | 34 | set-number x = 801 35 | number-string x to res 36 | 37 | .EE 38 | .RE 39 | 40 | The following will store "-238f" to string "res": 41 | 42 | .RS 4 43 | .EX 44 | 45 | set-number x = -9103 46 | number-string x to res base 16 47 | 48 | .EE 49 | .RE 50 | 51 | To print out a number -131: 52 | 53 | .RS 4 54 | .EX 55 | 56 | set-number x = -131 57 | number-string x 58 | 59 | .EE 60 | .RE 61 | 62 | .SH SEE ALSO 63 | Numbers 64 | 65 | \fBnumber-expressions\fP 66 | \fBnumber-string\fP 67 | \fBset-number\fP 68 | \fBstring-number\fP 69 | See all 70 | \fBdocumentation\fP 71 | -------------------------------------------------------------------------------- /docs/open-file.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | open-file \- (files) 4 | .SH PURPOSE 5 | Open file for reading and writing. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | open-file file-id \\ 13 | [ new-truncate ] \\ 14 | [ status ] 15 | 16 | .EE 17 | .RE 18 | 19 | .SH DESCRIPTION 20 | Opens file given by for reading and writing and creates an open file variable identified by . 21 | 22 | can be a full path name, or a path relative to the application home directory (see \fBdirectories\fP). 23 | 24 | You can obtain the status of file opening via number (in "status" clause). The is GG_OKAY if file is opened, or GG_ERR_OPEN if could not open file. 25 | 26 | If "new-truncate" clause is used, a new file is created if it doesn't exist, or it is truncated if it does. 27 | 28 | .SH EXAMPLES 29 | Create a file (or truncate an existing one), write 25,000 rows and the read back those rows and display them, then close file: 30 | 31 | .RS 4 32 | .EX 33 | 34 | %% /ofile public 35 | // Create new file, or truncate an old file if it exists 36 | open-file "testwrite" file-id nf new-truncate 37 | 38 | // Write 25000 rows 39 | start-loop repeat 25000 use i 40 | (( line 41 | @some text in line <> 42 | )) notrim 43 | string-length line to line_len 44 | write-file file-id nf from line length line_len 45 | end-loop 46 | 47 | // Rewind back to the beginning 48 | file-position set 0 file-id nf 49 | 50 | // Read all 25000 rows back, and print them out 51 | read-file file-id nf to whole_file 52 | p-out whole_file 53 | 54 | // Close the file 55 | close-file file-id nf 56 | %% 57 | 58 | .EE 59 | .RE 60 | 61 | .SH SEE ALSO 62 | Files 63 | 64 | \fBchange-mode\fP 65 | \fBclose-file\fP 66 | \fBcopy-file\fP 67 | \fBdelete-file\fP 68 | \fBfile-position\fP 69 | \fBfile-storage\fP 70 | \fBfile-uploading\fP 71 | \fBlock-file\fP 72 | \fBopen-file\fP 73 | \fBread-file\fP 74 | \fBread-line\fP 75 | \fBrename-file\fP 76 | \fBstat-file\fP 77 | \fBtemporary-file\fP 78 | \fBuniq-file\fP 79 | \fBunlock-file\fP 80 | \fBwrite-file\fP 81 | See all 82 | \fBdocumentation\fP 83 | -------------------------------------------------------------------------------- /docs/p-num.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | p-num \- (output) 4 | .SH PURPOSE 5 | Outputs a number. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | p-num [ new-line ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | p-num outputs a number given by variable. 19 | 20 | If "new-line" clause is used, then a new line ("\en") is output after . 21 | 22 | .SH EXAMPLES 23 | To output a number to a client: 24 | 25 | .RS 4 26 | .EX 27 | 28 | set-number x = 100 29 | p-num x 30 | 31 | .EE 32 | .RE 33 | 34 | .SH SEE ALSO 35 | Output 36 | 37 | \fBfinish-output\fP 38 | \fBflush-output\fP 39 | \fBoutput-statement\fP 40 | \fBpf-out\fP 41 | \fBpf-url\fP 42 | \fBpf-web\fP 43 | \fBp-num\fP 44 | \fBp-out\fP 45 | \fBp-path\fP 46 | \fBp-source-file\fP 47 | \fBp-source-line\fP 48 | \fBp-url\fP 49 | \fBp-web\fP 50 | See all 51 | \fBdocumentation\fP 52 | -------------------------------------------------------------------------------- /docs/p-out.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | p-out \- (output) 4 | .SH PURPOSE 5 | Outputs a string without encoding. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | p-out [ length ] [ new-line ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | p-out outputs a , without any encoding (meaning a string is output exactly as it appears). 19 | 20 | If "length" clause is used, then only leading bytes of are output. 21 | 22 | If "new-line" clause is used, then a new line ("\en") is output after . 23 | 24 | Note that all bytes of are output, even if contains null-bytes. 25 | 26 | .SH EXAMPLES 27 | To output data verbatim to a client: 28 | 29 | .RS 4 30 | .EX 31 | 32 | set-string mydata="Hello world" 33 | p-out mydata 34 | 35 | .EE 36 | .RE 37 | 38 | Writing to client, outputting text followed by a horizontal rule - the text is output to a client (such as browser) as it is, and the browser will interpret tags "
" and "
" as a line break and a horizonal line and display them as such: 39 | 40 | .RS 4 41 | .EX 42 | 43 | p-out "This is a non-encoded output
" new-line 44 | p-out "
" 45 | 46 | .EE 47 | .RE 48 | 49 | Create a query text string by means of \fBwrite-string\fP statement: 50 | 51 | .RS 4 52 | .EX 53 | 54 | // 55 | // Construct the run-time text of dynamic SQL 56 | // 57 | write-string qry_txt 58 | @select * from <> 59 | end-write-string 60 | 61 | .EE 62 | .RE 63 | 64 | .SH SEE ALSO 65 | Output 66 | 67 | \fBfinish-output\fP 68 | \fBflush-output\fP 69 | \fBoutput-statement\fP 70 | \fBpf-out\fP 71 | \fBpf-url\fP 72 | \fBpf-web\fP 73 | \fBp-num\fP 74 | \fBp-out\fP 75 | \fBp-path\fP 76 | \fBp-source-file\fP 77 | \fBp-source-line\fP 78 | \fBp-url\fP 79 | \fBp-web\fP 80 | See all 81 | \fBdocumentation\fP 82 | -------------------------------------------------------------------------------- /docs/p-path.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | p-path \- (output) 4 | .SH PURPOSE 5 | Outputs URL application and request path of a request handler. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | p-path [ new-line ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | p-path outputs a URL application path (see \fBrequest\fP) with following immediately afterwards. 19 | 20 | If no "--path" option in \fBgg\fP is used to specify URL application path, then it is the same as application name prepended with a forward slash: 21 | 22 | .RS 4 23 | .EX 24 | 25 | / 26 | 27 | .EE 28 | .RE 29 | 30 | p-path is used in construction of URLs or HTML forms (either for HTML or API) to refer back to the same application. 31 | 32 | Use \fBp-path\fP to create the absolute URL path to refer back to your service so you can issue \fBrequest\fPs to it. 33 | 34 | For example, this is a link that specifies request to service "show-notes": 35 | 36 | .RS 4 37 | .EX 38 | 39 | @>?date=yesterday">Show Notes 40 | 41 | .EE 42 | .RE 43 | 44 | If you are building HTML forms, you can add a note with: 45 | 46 | .RS 4 47 | .EX 48 | 49 | @
50 | @ 51 | @
52 | 53 | .EE 54 | .RE 55 | 56 | See \fBrequest\fP for more on URL structure. 57 | 58 | If "new-line" clause is used, then a new line ("\en") is output after the URL path. 59 | .SH SEE ALSO 60 | Output 61 | 62 | \fBfinish-output\fP 63 | \fBflush-output\fP 64 | \fBoutput-statement\fP 65 | \fBpf-out\fP 66 | \fBpf-url\fP 67 | \fBpf-web\fP 68 | \fBp-num\fP 69 | \fBp-out\fP 70 | \fBp-path\fP 71 | \fBp-source-file\fP 72 | \fBp-source-line\fP 73 | \fBp-url\fP 74 | \fBp-web\fP 75 | See all 76 | \fBdocumentation\fP 77 | -------------------------------------------------------------------------------- /docs/p-source-file.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | p-source-file \- (output) 4 | .SH PURPOSE 5 | Outputs the file name of the current source file. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | p-source-file [ new-line ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | p-source-file outputs the file name (relative to the source code directory) of the source file where the statement is located; this is often used for debugging. 19 | 20 | If "new-line" clause is used, then a new line ("\en") is output afterwards. 21 | 22 | .SH EXAMPLES 23 | 24 | .RS 4 25 | .EX 26 | 27 | @This file is <> 28 | 29 | .EE 30 | .RE 31 | 32 | .SH SEE ALSO 33 | Output 34 | 35 | \fBfinish-output\fP 36 | \fBflush-output\fP 37 | \fBoutput-statement\fP 38 | \fBpf-out\fP 39 | \fBpf-url\fP 40 | \fBpf-web\fP 41 | \fBp-num\fP 42 | \fBp-out\fP 43 | \fBp-path\fP 44 | \fBp-source-file\fP 45 | \fBp-source-line\fP 46 | \fBp-url\fP 47 | \fBp-web\fP 48 | See all 49 | \fBdocumentation\fP 50 | -------------------------------------------------------------------------------- /docs/p-source-line.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | p-source-line \- (output) 4 | .SH PURPOSE 5 | Outputs current line number in the source file. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | p-source-line [ new-line ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | p-source-line outputs the line number in the source file where the statement is located. It is often used for debugging purposes. 19 | 20 | If "new-line" clause is used, then a new line ("\en") is output afterwards. 21 | 22 | .SH EXAMPLES 23 | 24 | .RS 4 25 | .EX 26 | 27 | @This line is #<> 28 | 29 | .EE 30 | .RE 31 | 32 | .SH SEE ALSO 33 | Output 34 | 35 | \fBfinish-output\fP 36 | \fBflush-output\fP 37 | \fBoutput-statement\fP 38 | \fBpf-out\fP 39 | \fBpf-url\fP 40 | \fBpf-web\fP 41 | \fBp-num\fP 42 | \fBp-out\fP 43 | \fBp-path\fP 44 | \fBp-source-file\fP 45 | \fBp-source-line\fP 46 | \fBp-url\fP 47 | \fBp-web\fP 48 | See all 49 | \fBdocumentation\fP 50 | -------------------------------------------------------------------------------- /docs/p-url.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | p-url \- (output) 4 | .SH PURPOSE 5 | Outputs a URL-encoded string. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | p-url [ length ] [ new-line ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | p-url is the same as \fBp-out\fP, except that the output is URL-encoded. This means such output is suited for use in URL parameters. 19 | 20 | If "length" clause is used, then only leading bytes of are URL-encoded and then output. 21 | 22 | If "new-line" clause is used, then a new line ("\en") is output after encoded . 23 | 24 | .SH EXAMPLES 25 | Create a URL based on arbitrary strings used as URL parameters - for instance a space would be encoded as "%20" in the final output: 26 | 27 | .RS 4 28 | .EX 29 | 30 | @Update 31 | 32 | .EE 33 | .RE 34 | 35 | See \fBp-out\fP for more examples. 36 | .SH SEE ALSO 37 | Output 38 | 39 | \fBfinish-output\fP 40 | \fBflush-output\fP 41 | \fBoutput-statement\fP 42 | \fBpf-out\fP 43 | \fBpf-url\fP 44 | \fBpf-web\fP 45 | \fBp-num\fP 46 | \fBp-out\fP 47 | \fBp-path\fP 48 | \fBp-source-file\fP 49 | \fBp-source-line\fP 50 | \fBp-url\fP 51 | \fBp-web\fP 52 | See all 53 | \fBdocumentation\fP 54 | -------------------------------------------------------------------------------- /docs/p-web.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | p-web \- (output) 4 | .SH PURPOSE 5 | Outputs a web-encoded string. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | p-web [ length ] [ new-line ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | p-web is the same as \fBp-out\fP, except that the output is web-encoded (or HTML-encoded). This means such output is suited for use in web pages - the text will be displayed verbatim without HTML-markup being interpreted. 19 | 20 | If "length" clause is used, then only leading bytes of are web-encoded and then output. 21 | 22 | If "new-line" clause is used, then a new line ("\en") is output after encoded . 23 | 24 | .SH EXAMPLES 25 | Display "We use
markup" text, without "
" being displayed as a horizontal line: 26 | 27 | .RS 4 28 | .EX 29 | 30 | p-web "We use
markup" 31 | 32 | .EE 33 | .RE 34 | 35 | See \fBp-out\fP for more examples. 36 | .SH SEE ALSO 37 | Output 38 | 39 | \fBfinish-output\fP 40 | \fBflush-output\fP 41 | \fBoutput-statement\fP 42 | \fBpf-out\fP 43 | \fBpf-url\fP 44 | \fBpf-web\fP 45 | \fBp-num\fP 46 | \fBp-out\fP 47 | \fBp-path\fP 48 | \fBp-source-file\fP 49 | \fBp-source-line\fP 50 | \fBp-url\fP 51 | \fBp-web\fP 52 | See all 53 | \fBdocumentation\fP 54 | -------------------------------------------------------------------------------- /docs/pause-program.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | pause-program \- (time) 4 | .SH PURPOSE 5 | Pause request execution. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | pause-program 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | pause-program will delay request execution (i.e. sleep, meaning not utilize computing resources) for a number of . For instance: 19 | 20 | .RS 4 21 | .EX 22 | 23 | pause-program 1500 24 | 25 | .EE 26 | .RE 27 | 28 | will pause for 1.5 seconds. 29 | 30 | .SH EXAMPLES 31 | Pause execution for 0.25 seconds: 32 | 33 | .RS 4 34 | .EX 35 | 36 | pause-program 250 37 | 38 | .EE 39 | .RE 40 | 41 | .SH SEE ALSO 42 | Time 43 | 44 | \fBget-time\fP 45 | \fBpause-program\fP 46 | See all 47 | \fBdocumentation\fP 48 | -------------------------------------------------------------------------------- /docs/permissions.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | permissions \- Golf documentation (general) 4 | .SH DESCRIPTION 5 | File and directory permissions are given with standard Linux permissions. A permission "mode" is typically given as an octal number (such as 0750), where each digit is made of read (carrying value of 4), write (carrying value of 2) and execute/search permissions (carrying value of 1), so for example 7 means having read, write and execute/search permissions (since 7=4+2+1). The first digit refers to permissions given to user, second digit to those given to user's group, and third digit to those given to everyone. 6 | 7 | Files in Golf \fBdirectories\fP are generally created with 700 privileges, meaning only the user who owns the application can access them and other users (even within the same group) cannot. The same goes for directories created by \fBnew-dir\fP by default, unless "mode" specifies differently. 8 | 9 | Files created by Golf (including \fBopen-file\fP and \fBwrite-file\fP) are created with 600 permissions, meaning only the user who owns the application can access them and other users (even within the same group) cannot. 10 | 11 | You can use \fBstat-file\fP to obtain permission mode for a file or directory, and \fBchange-mode\fP to set it. Note that, most of the time, you won't need to do this at all. If you do, however, you should change permission modes carefully and keep in mind the implications for both your application's security and functionality. 12 | .SH SEE ALSO 13 | General 14 | 15 | \fBabout-golf\fP 16 | \fBdirectories\fP 17 | \fBpermissions\fP 18 | See all 19 | \fBdocumentation\fP 20 | -------------------------------------------------------------------------------- /docs/pf-url.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | pf-url \- (output) 4 | .SH PURPOSE 5 | Outputs a URL-encoded formatted string. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | pf-url , [ , ]... \\ 13 | [ to-error ] \\ 14 | [ to ] 15 | 16 | .EE 17 | .RE 18 | 19 | .SH DESCRIPTION 20 | pf-url is the same as \fBpf-out\fP, except that the output is URL-encoded. This means such output is suited for use in URL parameters. 21 | 22 | .SH EXAMPLES 23 | Create a URL based on arbitrary strings used as URL parameters - for instance space would be encoded as "%20" in the final output: 24 | 25 | .RS 4 26 | .EX 27 | 28 | @Log transaction 29 | 30 | .EE 31 | .RE 32 | 33 | See \fBpf-out\fP for more examples. 34 | .SH SEE ALSO 35 | Output 36 | 37 | \fBfinish-output\fP 38 | \fBflush-output\fP 39 | \fBoutput-statement\fP 40 | \fBpf-out\fP 41 | \fBpf-url\fP 42 | \fBpf-web\fP 43 | \fBp-num\fP 44 | \fBp-out\fP 45 | \fBp-path\fP 46 | \fBp-source-file\fP 47 | \fBp-source-line\fP 48 | \fBp-url\fP 49 | \fBp-web\fP 50 | See all 51 | \fBdocumentation\fP 52 | -------------------------------------------------------------------------------- /docs/pf-web.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | pf-web \- (output) 4 | .SH PURPOSE 5 | Outputs a web-encoded formatted string. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | pf-web , [ , ]... \\ 13 | [ to-error ] \\ 14 | [ to ] 15 | 16 | .EE 17 | .RE 18 | 19 | .SH DESCRIPTION 20 | pf-web is the same as \fBpf-out\fP, except that the output is web-encoded (or HTML-encoded). This means such output is suited for use in web pages - meaning any HTML-markup will be properly encoded. 21 | 22 | .SH EXAMPLES 23 | Display text containing HTML tags without them being rendered in the browser: 24 | 25 | .RS 4 26 | .EX 27 | 28 | pf-web "We use %s markup", "
" 29 | 30 | .EE 31 | .RE 32 | 33 | See \fBpf-out\fP for more examples. 34 | .SH SEE ALSO 35 | Output 36 | 37 | \fBfinish-output\fP 38 | \fBflush-output\fP 39 | \fBoutput-statement\fP 40 | \fBpf-out\fP 41 | \fBpf-url\fP 42 | \fBpf-web\fP 43 | \fBp-num\fP 44 | \fBp-out\fP 45 | \fBp-path\fP 46 | \fBp-source-file\fP 47 | \fBp-source-line\fP 48 | \fBp-url\fP 49 | \fBp-web\fP 50 | See all 51 | \fBdocumentation\fP 52 | -------------------------------------------------------------------------------- /docs/position-list.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | position-list \- (linked-list) 4 | .SH PURPOSE 5 | Set current element in a linked list. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | position-list \\ 13 | [ first | last | end | previous | next | \\ 14 | [ status ] 15 | 16 | .EE 17 | .RE 18 | 19 | .SH DESCRIPTION 20 | position-list changes the current element of linked . A current element is the one that is read with \fBread-list\fP. A newly added element is written with \fBwrite-list\fP by inserting it just before the current element, thus becoming a new current element. Reading from does not change its current element; use position-list to explicitly change it. 21 | 22 | To position to the first element, use "first" clause. Use "last" clause to make the last element the current one. Use "previous" and "next" to change the current element to just before or just after it. 23 | 24 | A position just beyond the last element in is considered the "end" of it; in this case write-list will append an element to and this element becomes its last, which is equivalent to using write-list statement with "append" clause. 25 | 26 | Use "end" clause to set current element to 's end. Note that "end" clause is equivalent to using "next" clause on the the last element in . 27 | 28 | If you attempt to position prior to the first element, after the end of , or anywhere in an empty list, then number (in "status" clause") is GG_ERR_EXIST, otherwise it is GG_OKAY. Note that if is GG_ERR_EXIST, the current element will not change. 29 | 30 | .SH EXAMPLES 31 | Position to the next element in list: 32 | 33 | .RS 4 34 | .EX 35 | 36 | position-list mylist next status st 37 | if-true st equal GG_ERR_EXIST 38 | @Beyond the end of list 39 | end-if 40 | 41 | .EE 42 | .RE 43 | 44 | Position to the first element in list: 45 | 46 | .RS 4 47 | .EX 48 | 49 | position-list mylist first 50 | 51 | .EE 52 | .RE 53 | 54 | .SH SEE ALSO 55 | Linked list 56 | 57 | \fBdelete-list\fP 58 | \fBget-list\fP 59 | \fBnew-list\fP 60 | \fBposition-list\fP 61 | \fBpurge-list\fP 62 | \fBread-list\fP 63 | \fBwrite-list\fP 64 | See all 65 | \fBdocumentation\fP 66 | -------------------------------------------------------------------------------- /docs/postgresql-database.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | postgresql-database \- Golf documentation (database) 4 | .SH DESCRIPTION 5 | Postgres database configuration file has a Postgres connection string. 6 | 7 | You can see the parameters available at \fBhttps://www.postgresql.org/docs/14/libpq-connect.html#LIBPQ-CONNSTRING\fP. 8 | 9 | Most of the time, though, you may be using only a few of those options, as in: 10 | 11 | .RS 4 12 | .EX 13 | 14 | user=myuser password=mypwd dbname=mydb 15 | 16 | .EE 17 | .RE 18 | 19 | The above file has parameters "user" (Postgres user), "password" (the password for Postgres user), "dbname" (the Postgres database name). If you use peer-authenticated (i.e. passwordless) login, then omit "password" - this is when the Postgres user name is the same as your Operating System user name and where local unix domain socket is used for authentication. 20 | .SH SEE ALSO 21 | Database 22 | 23 | \fBbegin-transaction\fP 24 | \fBcommit-transaction\fP 25 | \fBcurrent-row\fP 26 | \fBdatabase-config-file\fP 27 | \fBdb-error\fP 28 | \fBmariadb-database\fP 29 | \fBpostgresql-database\fP 30 | \fBrollback-transaction\fP 31 | \fBrun-query\fP 32 | \fBsqlite-database\fP 33 | See all 34 | \fBdocumentation\fP 35 | -------------------------------------------------------------------------------- /docs/purge-array.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | purge-array \- (array) 4 | .SH PURPOSE 5 | Purge an array. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | purge-array 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | purge-array deletes all elements from that was created with \fBnew-array\fP. 19 | 20 | After purge-array, you can use it without calling \fBnew-array\fP again; the array is initialized as if it was just created that way. 21 | 22 | .SH EXAMPLES 23 | Create an array, put some data in it and then delete the data: 24 | 25 | .RS 4 26 | .EX 27 | 28 | new-array arr 29 | write-array arr key 50 value "myvalue" 30 | purge-array arr 31 | 32 | .EE 33 | .RE 34 | 35 | See \fBread-array\fP for more examples. 36 | .SH SEE ALSO 37 | Array 38 | 39 | \fBnew-array\fP 40 | \fBpurge-array\fP 41 | \fBread-array\fP 42 | \fBwrite-array\fP 43 | See all 44 | \fBdocumentation\fP 45 | -------------------------------------------------------------------------------- /docs/purge-fifo.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | purge-fifo \- (FIFO) 4 | .SH PURPOSE 5 | Delete FIFO list data. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | purge-fifo 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | purge-fifo will delete all elements from the FIFO , created by \fBnew-fifo\fP. The list is then empty and you can still put data into it, and get data from it afterwards, without having to call \fBnew-fifo\fP again. 19 | 20 | All keys or values stored in the list are also deleted. 21 | 22 | .SH EXAMPLES 23 | See \fBread-fifo\fP. 24 | .SH SEE ALSO 25 | FIFO 26 | 27 | \fBdelete-fifo\fP 28 | \fBnew-fifo\fP 29 | \fBpurge-fifo\fP 30 | \fBread-fifo\fP 31 | \fBrewind-fifo\fP 32 | \fBwrite-fifo\fP 33 | See all 34 | \fBdocumentation\fP 35 | -------------------------------------------------------------------------------- /docs/purge-hash.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | purge-hash \- (hash) 4 | .SH PURPOSE 5 | Purge a hash. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | purge-hash 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | purge-hash deletes all elements from that was created with \fBnew-hash\fP. 19 | 20 | After purge-hash, you can use it without calling \fBnew-hash\fP again. Note however, that "average-reads" statistics (see \fBget-hash\fP) is not reset - it keeps being computed and remains for the life of the hash. 21 | 22 | .SH EXAMPLES 23 | Create a hash, put some data in it and then delete the data: 24 | 25 | .RS 4 26 | .EX 27 | 28 | new-hash h 29 | write-hash h key "mykey" value "myvalue" 30 | purge-hash h 31 | 32 | .EE 33 | .RE 34 | 35 | See \fBread-hash\fP for more examples. 36 | .SH SEE ALSO 37 | Hash 38 | 39 | \fBget-hash\fP 40 | \fBnew-hash\fP 41 | \fBpurge-hash\fP 42 | \fBread-hash\fP 43 | \fBresize-hash\fP 44 | \fBwrite-hash\fP 45 | See all 46 | \fBdocumentation\fP 47 | -------------------------------------------------------------------------------- /docs/purge-lifo.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | purge-lifo \- (LIFO) 4 | .SH PURPOSE 5 | Delete LIFO list data. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | purge-lifo 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | purge-lifo will delete all elements from the LIFO created by \fBnew-lifo\fP, including all keys and values. The list is then empty and you can still put data into it, and get data from it afterwards, without having to call \fBnew-lifo\fP again. 19 | 20 | .SH EXAMPLES 21 | See \fBread-lifo\fP. 22 | .SH SEE ALSO 23 | LIFO 24 | 25 | \fBdelete-lifo\fP 26 | \fBnew-lifo\fP 27 | \fBpurge-lifo\fP 28 | \fBread-lifo\fP 29 | \fBrewind-lifo\fP 30 | \fBwrite-lifo\fP 31 | See all 32 | \fBdocumentation\fP 33 | -------------------------------------------------------------------------------- /docs/purge-list.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | purge-list \- (linked-list) 4 | .SH PURPOSE 5 | Delete linked list data. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | purge-list 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | purge-list will delete all elements (including their keys and values) from the linked , created by \fBnew-list\fP. The list is then empty and you can still put data into it, and get data from it afterwards, without having to call \fBnew-list\fP again. 19 | 20 | .SH EXAMPLES 21 | See \fBread-list\fP. 22 | .SH SEE ALSO 23 | Linked list 24 | 25 | \fBdelete-list\fP 26 | \fBget-list\fP 27 | \fBnew-list\fP 28 | \fBposition-list\fP 29 | \fBpurge-list\fP 30 | \fBread-list\fP 31 | \fBwrite-list\fP 32 | See all 33 | \fBdocumentation\fP 34 | -------------------------------------------------------------------------------- /docs/purge-tree.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | purge-tree \- (tree) 4 | .SH PURPOSE 5 | Delete all tree nodes. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | purge-tree 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | purge-tree will delete all nodes; must have been created with \fBnew-tree\fP. All of 's nodes, and their keys/values all deleted. 19 | 20 | After purge-tree, the tree is empty and you can use it again (write into it, read from it etc.). 21 | 22 | .SH EXAMPLES 23 | Delete all tree data: 24 | 25 | .RS 4 26 | .EX 27 | 28 | new-tree mytree 29 | \[char46].. 30 | purge-tree mytree 31 | 32 | .EE 33 | .RE 34 | 35 | .SH SEE ALSO 36 | Tree 37 | 38 | \fBdelete-tree\fP 39 | \fBget-tree\fP 40 | \fBnew-tree\fP 41 | \fBpurge-tree\fP 42 | \fBread-tree\fP 43 | \fBuse-cursor\fP 44 | \fBwrite-tree\fP 45 | See all 46 | \fBdocumentation\fP 47 | -------------------------------------------------------------------------------- /docs/random-crypto.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | random-crypto \- (encryption) 4 | .SH PURPOSE 5 | Obtain a random string for cryptographic use. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | random-crypto to \\ 13 | [ length ] 14 | 15 | .EE 16 | .RE 17 | 18 | .SH DESCRIPTION 19 | random-crypto obtains a random string of length . This statement uses a cryptographically secure pseudo random generator (CSPRNG) from OpenSSL library. If "length" clause is omitted, the length is 20 by default. 20 | 21 | The value generated is always binary and may contain null-characters and is null-terminated. 22 | 23 | Use this statement only when needed for specific cryptographic uses. In all other cases, use \fBrandom-string\fP which is considerably faster. 24 | 25 | .SH EXAMPLES 26 | Get a 20-digit long random binary value: 27 | 28 | .RS 4 29 | .EX 30 | 31 | random-crypto to str length 20 32 | 33 | .EE 34 | .RE 35 | 36 | .SH SEE ALSO 37 | Encryption 38 | 39 | \fBdecrypt-data\fP 40 | \fBderive-key\fP 41 | \fBencrypt-data\fP 42 | \fBhash-string\fP 43 | \fBhmac-string\fP 44 | \fBrandom-crypto\fP 45 | \fBrandom-string\fP 46 | See all 47 | \fBdocumentation\fP 48 | -------------------------------------------------------------------------------- /docs/random-string.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | random-string \- (encryption) 4 | .SH PURPOSE 5 | Obtain a random string. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | random-string to \\ 13 | [ length ] \\ 14 | [ number | binary ] 15 | 16 | .EE 17 | .RE 18 | 19 | .SH DESCRIPTION 20 | random-string obtains a random string of length . If "length" clause is omitted, the length is 20 by default. 21 | 22 | If "number" clause is used, then the resulting string is composed of digits only ("0" through "9"). 23 | 24 | If "binary" clause is used, then the resulting string is binary, i.e. each byte can have an unsigned value of 0-255. 25 | 26 | By default, if neither "number" or "binary" is used, the resulting string is alphanumeric, i.e. digits ("0" through "9") and alphabet letters ("a"-"z" and "A"-"Z") are used only. 27 | 28 | Random generator is based on the Linux random() generator seeded by local process properties such as its PID and time. A single process is seeded once, and thus any number of requests served by the same process will use a subset of the process' random sequence. Due to joint entropy, each result given to any request is random, not just within a single request, but among any number of different requests. 29 | 30 | .SH EXAMPLES 31 | Get a 100-digit long random value (as an alphanumeric string): 32 | 33 | .RS 4 34 | .EX 35 | 36 | random-string to str length 100 37 | pf-out "%s\en", str 38 | 39 | .EE 40 | .RE 41 | 42 | Get a random number of length 10 in string representation: 43 | 44 | .RS 4 45 | .EX 46 | 47 | random-string to str length 10 number 48 | pf-out "%s\en", str 49 | 50 | .EE 51 | .RE 52 | 53 | Get a random binary value that is 8 bytes in length - this value may contain null bytes (i.e. it will contain bytes with values ranging from 0 to 255): 54 | 55 | .RS 4 56 | .EX 57 | 58 | random-string to str length 8 binary 59 | 60 | .EE 61 | .RE 62 | 63 | .SH SEE ALSO 64 | Encryption 65 | 66 | \fBdecrypt-data\fP 67 | \fBderive-key\fP 68 | \fBencrypt-data\fP 69 | \fBhash-string\fP 70 | \fBhmac-string\fP 71 | \fBrandom-crypto\fP 72 | \fBrandom-string\fP 73 | See all 74 | \fBdocumentation\fP 75 | -------------------------------------------------------------------------------- /docs/read-array.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | read-array \- (array) 4 | .SH PURPOSE 5 | Get data from an array. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | read-array \\ 13 | key \\ 14 | value \\ 15 | [ delete [ ] ] \\ 16 | [ status ] 17 | 18 | .EE 19 | .RE 20 | 21 | .SH DESCRIPTION 22 | read-array will obtain an element from , which is a string (in "value" clause) based on a number (in "key" clause). is a number from 0 up to (excluding) the currently allocated array size. Note that array may be allocated beyond the highest index of an element written to it. was created by \fBnew-array\fP. 23 | 24 | You can also delete an element from the array by using "delete" clause - the is still obtained though it is no longer in the array. The array element is deleted if "delete" clause is used without boolean variable , or if evaluates to true. 25 | 26 | If no was found in the array (meaning an array element with index was either never written or was deleted), then number (in "status" clause) is GG_ERR_EXIST and is unchanged, otherwise is GG_OKAY. 27 | 28 | .SH EXAMPLES 29 | In this example, a new array is created, a value is written to it, and then the value is obtained and the element deleted; return status is checked: 30 | 31 | .RS 4 32 | .EX 33 | 34 | // Create new array 35 | new-array arr 36 | 37 | // Write to array 38 | write-array arr key 500 value "some data" 39 | 40 | // Read from array 41 | read-array arr key 500 value res status st delete 42 | if-true st equal GG_ERR_EXIST 43 | @No data in the array at index 500! 44 | else-if 45 | @Deleted value is <> 46 | end-if 47 | 48 | .EE 49 | .RE 50 | 51 | .SH SEE ALSO 52 | Array 53 | 54 | \fBnew-array\fP 55 | \fBpurge-array\fP 56 | \fBread-array\fP 57 | \fBwrite-array\fP 58 | See all 59 | \fBdocumentation\fP 60 | -------------------------------------------------------------------------------- /docs/read-fifo.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | read-fifo \- (FIFO) 4 | .SH PURPOSE 5 | Reads key/value pair from a FIFO list. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | read-fifo \\ 13 | key \\ 14 | value \\ 15 | [ status ] 16 | 17 | .EE 18 | .RE 19 | 20 | .SH DESCRIPTION 21 | read-fifo retrieves an element from the FIFO into string (in "key" clause) and string (in "value" clause). 22 | 23 | Once an element has been retrieved, the next use of read-fifo will obtain the following one, in the same order they were put in. read-fifo starts with the first element put in, and moves forward from there, unless \fBrewind-fifo\fP is called, which positions back to the first one. 24 | 25 | If the element is successfully retrieved, number (in "status" clause) is GG_OKAY, otherwise it is GG_ERR_EXIST, which means there are no more elements to retrieve. 26 | 27 | .SH EXAMPLES 28 | In this example, a FIFO list is created, and two key/value pairs added. They are then retrieved in a loop and printed out (twice with rewind), and then the list is purged: 29 | 30 | .RS 4 31 | .EX 32 | 33 | // Create a list 34 | new-fifo mylist 35 | 36 | // Add data to the list 37 | write-fifo mylist key "key1" value "value1" 38 | write-fifo mylist key "some2" value "other2" 39 | 40 | start-loop 41 | // Get data from the list 42 | read-fifo mylist key k value v status st 43 | 44 | // Check if no more data 45 | if-true st not-equal GG_OKAY 46 | break-loop 47 | end-if 48 | 49 | @Obtained key <> with value <> 50 | end-loop 51 | 52 | // Go through the list again, use rewind-fifo for that 53 | rewind-fifo mylist 54 | 55 | start-loop 56 | read-fifo mylist key k value v status st 57 | if-true st not-equal GG_OKAY 58 | break-loop 59 | end-if 60 | @Again obtained key <> with value <> 61 | end-loop 62 | 63 | purge-fifo mylist 64 | 65 | .EE 66 | .RE 67 | 68 | .SH SEE ALSO 69 | FIFO 70 | 71 | \fBdelete-fifo\fP 72 | \fBnew-fifo\fP 73 | \fBpurge-fifo\fP 74 | \fBread-fifo\fP 75 | \fBrewind-fifo\fP 76 | \fBwrite-fifo\fP 77 | See all 78 | \fBdocumentation\fP 79 | -------------------------------------------------------------------------------- /docs/read-json.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | read-json \- (JSON-parsing) 4 | .SH PURPOSE 5 | Read data elements of JSON document. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | read-json \\ 13 | [ key ] \\ 14 | [ value ] \\ 15 | [ type ] \\ 16 | [ next ] 17 | 18 | .EE 19 | .RE 20 | 21 | .SH DESCRIPTION 22 | read-json reads data elements from variable, which is created with \fBjson-doc\fP. A data element is a string / pair of a leaf node, where key (in "key" clause) is a normalized key name, which is the value's name preceded with the names of all objects and array members leading up to it, separated by a dot ("."). 23 | 24 | The actual is obtained with "value" clause, and the of value can be obtained with "type" clause. 25 | 26 | is a number that can be GG_JSON_TYPE_STRING, GG_JSON_TYPE_NUMBER, GG_JSON_TYPE_REAL, GG_JSON_TYPE_BOOL and GG_JSON_TYPE_NULL for string, number, real (floating point), boolean and null values respectively. Note that is always a string representation of these types. 27 | 28 | Use "next" clause to move to the next sequential key/value pair in the document, from top down. Typically, you would get a key first, examine if it's of interest to you, and then obtain value. This is because Golf uses "lazy" approach where value is not copied until needed; with this approach JSON parsing is faster. You can use also use "key", "value" and "next" at the same time if you're going through all elements. 29 | 30 | If there are no more data elements to read, is GG_JSON_TYPE_NONE. 31 | 32 | in "key" clause is a normalized name of any given leaf node in JSON text. This means every non-leaf node is included (such as arrays and objects), separated by a dot ("."), and arrays are indexed with "[]". An example would be: 33 | 34 | .RS 4 35 | .EX 36 | 37 | "menu"."popup"."menuitem"[1]."onclick" 38 | 39 | .EE 40 | .RE 41 | 42 | 43 | .SH EXAMPLES 44 | See \fBjson-doc\fP. 45 | .SH SEE ALSO 46 | JSON parsing 47 | 48 | \fBjson-doc\fP 49 | \fBread-json\fP 50 | See all 51 | \fBdocumentation\fP 52 | -------------------------------------------------------------------------------- /docs/read-message.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | read-message \- (messages) 4 | .SH PURPOSE 5 | Read key/value from message. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | read-message \\ 13 | key \\ 14 | value \\ 15 | [ status 16 | 17 | .EE 18 | .RE 19 | 20 | .SH DESCRIPTION 21 | read-message reads strings (in "key" clause) and (in "value" clause) from , which must have been created with \fBnew-message\fP. 22 | 23 | The reading of key/value pairs starts from the beginning of message and proceeds sequentially forward. Once a key/value pair is read it cannot be read again. 24 | 25 | number (in "status" clause) will be GG_OKAY for a successful read, GG_ERR_FORMAT if message is not in \fBSEMI\fP format or GG_ERR_LENGTH if message isn't of proper length. 26 | 27 | Once a message is read from, it cannot be written to (see \fBwrite-message\fP). 28 | 29 | .SH EXAMPLES 30 | See \fBnew-message\fP. 31 | .SH SEE ALSO 32 | Messages 33 | 34 | \fBget-message\fP 35 | \fBnew-message\fP 36 | \fBread-message\fP 37 | \fBSEMI\fP 38 | \fBwrite-message\fP 39 | See all 40 | \fBdocumentation\fP 41 | -------------------------------------------------------------------------------- /docs/read-split.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | read-split \- (strings) 4 | .SH PURPOSE 5 | Obtain split string pieces. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | read-split from to [ status ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | read-split will read split string pieces from which is produced by \fBsplit-string\fP. is the number (starting with 1) of the piece to retrieve in string . number (in "status" clause) is GG_OKAY if successful, or GG_ERR_OVERFLOW if is not valid (meaning it's outside of the range of pieces parsed by split-string). 19 | 20 | .SH EXAMPLES 21 | See \fBsplit-string\fP. 22 | .SH SEE ALSO 23 | Strings 24 | 25 | \fBconcatenate-strings\fP 26 | \fBcopy-string\fP 27 | \fBcount-substring\fP 28 | \fBdelete-string\fP 29 | \fBlower-string\fP 30 | \fBread-split\fP 31 | \fBreplace-string\fP 32 | \fBset-string\fP 33 | \fBsplit-string\fP 34 | \fBstring-length\fP 35 | \fBtrim-string\fP 36 | \fBupper-string\fP 37 | \fBwrite-string\fP 38 | See all 39 | \fBdocumentation\fP 40 | -------------------------------------------------------------------------------- /docs/read-xml.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | read-xml \- (XML-parsing) 4 | .SH PURPOSE 5 | Read data elements from XML document. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | read-xml \\ 13 | [ key ] \\ 14 | [ value ] \\ 15 | [ status ] \\ 16 | [ next ] 17 | 18 | .EE 19 | .RE 20 | 21 | .SH DESCRIPTION 22 | read-xml reads data elements from variable, which is created with \fBxml-doc\fP. A data element is a string / pair, where key (in "key" clause) is a normalized key name, which is the current name preceded with the names of all elements leading up to it, separated by a forward slash ("/"). Node that attribute elements end with "@". 23 | 24 | The actual is obtained with "value" clause, and the can be obtained with "status" clause. is GG_OKAY if key/value is obtained, and GG_ERR_EXIST if there are no more to get. 25 | 26 | Use "next" clause to move to the next sequential key/value pair in the document, from top down as available. Typically, you would get a key first, examine if it's of interest to you, and then obtain value. You can use also use "key", "value" and "next" at the same time if you're going through all elements. 27 | 28 | in "key" clause is a normalized name of any given element in XML text. This means every non-leaf element is included, separated by a forward slash ("/"), and arguments end with "@". An example would be, if "onclick" is a element of "menuitem": 29 | 30 | .RS 4 31 | .EX 32 | 33 | menu/popup/menuitem/onclick 34 | 35 | .EE 36 | .RE 37 | 38 | or if "onclick" is an attribute of "menuitem": 39 | 40 | .RS 4 41 | .EX 42 | 43 | menu/popup/menuitem/onclick/@ 44 | 45 | .EE 46 | .RE 47 | 48 | 49 | .SH EXAMPLES 50 | See \fBxml-doc\fP. 51 | .SH SEE ALSO 52 | XML parsing 53 | 54 | \fBread-xml\fP 55 | \fBxml-doc\fP 56 | See all 57 | \fBdocumentation\fP 58 | -------------------------------------------------------------------------------- /docs/rename-file.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | rename-file \- (files) 4 | .SH PURPOSE 5 | Renames a file. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | rename-file to [ status ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | rename-file will rename to . number is GG_OKAY on success and GG_ERR_RENAME on failure. 19 | 20 | and must be specified with full paths unless they are in the current working directory (see \fBdirectories\fP), in which case a name alone will suffice. and can be in different directories. 21 | 22 | .SH EXAMPLES 23 | Rename files: 24 | 25 | .RS 4 26 | .EX 27 | 28 | rename-file "/home/u1/d1/f1" to "/home/u1/d2/f2" status st 29 | if-true st equal GG_OKAY 30 | @Rename successful.
31 | end-if 32 | 33 | .EE 34 | .RE 35 | 36 | Rename files in the current working directory: 37 | 38 | .RS 4 39 | .EX 40 | 41 | rename-file "f1" to "f2" status st 42 | if-true st equal GG_OKAY 43 | @Rename successful.
44 | end-if 45 | 46 | .EE 47 | .RE 48 | 49 | .SH SEE ALSO 50 | Files 51 | 52 | \fBchange-mode\fP 53 | \fBclose-file\fP 54 | \fBcopy-file\fP 55 | \fBdelete-file\fP 56 | \fBfile-position\fP 57 | \fBfile-storage\fP 58 | \fBfile-uploading\fP 59 | \fBlock-file\fP 60 | \fBopen-file\fP 61 | \fBread-file\fP 62 | \fBread-line\fP 63 | \fBrename-file\fP 64 | \fBstat-file\fP 65 | \fBtemporary-file\fP 66 | \fBuniq-file\fP 67 | \fBunlock-file\fP 68 | \fBwrite-file\fP 69 | See all 70 | \fBdocumentation\fP 71 | -------------------------------------------------------------------------------- /docs/report-error.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | report-error \- (error-handling) 4 | .SH PURPOSE 5 | Reports a fatal error. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | report-error , [ , ... ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | report-error will report a fatal error. It will format an error message according to the string and a list of s and then write it in the trace file (see \fBdirectories\fP); this happens regardless of whether tracing is enabled or not. 19 | 20 | See \fBerror-handling\fP when report-error is called. 21 | 22 | string must be present and there must be at least one (it means if you want to trace a simple string literal you still have to use "%s" as format). The reason for this is to avoid formatting errors, and to use formatting in a consistent fashion. 23 | 24 | 25 | .LP 26 | .B FORMAT 27 | .LP 28 | 29 | string must be a literal. Variables must follow separated by commas in the same order as placeholders. If you use any placeholders other than specified below, or the type of variables you use do not match the type of a corresponding placeholder in , your program will \fBerror out\fP. You can use the following placeholders in (see \fBtrace-run\fP for an example of usage): 30 | 31 | .RS 4 32 | \[bu] 33 | %s for a string 34 | 35 | .RE 36 | 37 | .RS 4 38 | \[bu] 39 | %s for a string output with a width of at least (any excess filled with spaces to the left), 40 | 41 | .RE 42 | 43 | .RS 4 44 | \[bu] 45 | %ld for a number 46 | 47 | .RE 48 | 49 | .RS 4 50 | \[bu] 51 | %ld for a number output with a width of at least (any excess filled with spaces to the left) 52 | .RE 53 | 54 | 55 | .SH EXAMPLES 56 | 57 | .RS 4 58 | .EX 59 | 60 | report-error "Too many input parameters for %s, encountered total of [%ld]", "customer", num_count 61 | 62 | .EE 63 | .RE 64 | 65 | .SH SEE ALSO 66 | Error handling 67 | 68 | \fBdb-error\fP 69 | \fBerror-code\fP 70 | \fBerror-handling\fP 71 | \fBreport-error\fP 72 | See all 73 | \fBdocumentation\fP 74 | -------------------------------------------------------------------------------- /docs/request-body.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | request-body \- (request-data) 4 | .SH PURPOSE 5 | Get the body of an HTTP request. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | request-body 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | request-body stores the request body of an HTTP request into string . 19 | 20 | If the content type of the request is "multipart/form-data", the request body is empty because all the data (including any attached files) can be obtained by using \fBget-param\fP (see \fBfile-uploading\fP for files). In all other cases, request body is available. 21 | 22 | Typical use of request-body is when some text or binary information is attached to the request, such as JSON for example, though it can be anything else, for example an image, some text, or a PDF document. Usually request body is present for POST, PUT or PATCH requests, but you can also obtain it for GET or DELETE requests, if supplied (for instance identifying a resource may require more information than can fit in a query string), or for any custom request method. 23 | 24 | .SH EXAMPLES 25 | String variable "reqb" will hold request body of a request: 26 | 27 | .RS 4 28 | .EX 29 | 30 | request-body reqb 31 | 32 | .EE 33 | .RE 34 | 35 | .SH SEE ALSO 36 | Request data 37 | 38 | \fBget-param\fP 39 | \fBrequest-body\fP 40 | \fBset-param\fP 41 | See all 42 | \fBdocumentation\fP 43 | -------------------------------------------------------------------------------- /docs/resize-hash.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | resize-hash \- (hash) 4 | .SH PURPOSE 5 | Resize hash table. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | resize-hash hash-size 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | resize-hash will resize table (created by \fBnew-hash\fP) to size , which refers to the number of "buckets", or possible hash codes derived from keys stored. 19 | 20 | When a number of elements stored grows, the search performance may decline if hash size remains the same. Consequently, if the number of elements shrinks, the memory allocated by the hash may be wasted. Use \fBget-hash\fP to obtain its current hash-size, its length (the number of elements currently stored in it) and the statistics (such as average reads) to determine if you need to resize it. 21 | 22 | Resizing is generally expensive, so it should not be done too often, and only when needed. The goal is to amortize this expense through future gain of lookup performance. For that reason it may be better to resize proportionally (i.e. by a percentage), unless you have a specific application reason to do otherwise, or to avoid exponential growth. 23 | 24 | .SH EXAMPLES 25 | 26 | .RS 4 27 | .EX 28 | 29 | resize-hash h hash-size 100000 30 | 31 | .EE 32 | .RE 33 | 34 | .SH SEE ALSO 35 | Hash 36 | 37 | \fBget-hash\fP 38 | \fBnew-hash\fP 39 | \fBpurge-hash\fP 40 | \fBread-hash\fP 41 | \fBresize-hash\fP 42 | \fBwrite-hash\fP 43 | See all 44 | \fBdocumentation\fP 45 | -------------------------------------------------------------------------------- /docs/return-handler.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | return-handler \- (program-flow) 4 | .SH PURPOSE 5 | Return from current request handler back to its caller. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | return-handler 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | Returns from current request handler by transferring control back to its caller. If the current request handler was called from an outside caller (such as web browser, API, command line etc.), then return-handler is equivalent to \fBexit-handler\fP. If the current request handler was called from another request handler with \fBcall-handler\fP, then control transfers back to that handler immediately after call-handler. 19 | 20 | .SH EXAMPLES 21 | In this example, "req-handler" (the caller) will call "other-handler" (the callee), which will return to the caller (immediately after call-handler). Here's the caller: 22 | 23 | .RS 4 24 | .EX 25 | 26 | begin-handler /req-handler public 27 | ... 28 | call-handler other-handler 29 | ... 30 | end-handler 31 | 32 | .EE 33 | .RE 34 | 35 | The callee handler: 36 | 37 | .RS 4 38 | .EX 39 | 40 | begin-handler /other-handler public 41 | ... 42 | return-handler 43 | ... 44 | end-handler 45 | 46 | .EE 47 | .RE 48 | 49 | .SH SEE ALSO 50 | Program flow 51 | 52 | \fBbreak-loop\fP 53 | \fBcode-blocks\fP 54 | \fBcontinue-loop\fP 55 | \fBdo-once\fP 56 | \fBexit-handler\fP 57 | \fBif-defined\fP 58 | \fBif-true\fP 59 | \fBreturn-handler\fP 60 | \fBset-bool\fP 61 | \fBstart-loop\fP 62 | See all 63 | \fBdocumentation\fP 64 | -------------------------------------------------------------------------------- /docs/rewind-fifo.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | rewind-fifo \- (FIFO) 4 | .SH PURPOSE 5 | Rewind FIFO list to the beginning. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | rewind-fifo 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | rewind-fifo will position at the very first data element put into which was created with \fBnew-fifo\fP. Each time \fBread-fifo\fP is used, the internal position moves to the next element in the order they were put in. rewind-fifo rewinds back to the very first one. 19 | 20 | .SH EXAMPLES 21 | See \fBread-fifo\fP. 22 | .SH SEE ALSO 23 | FIFO 24 | 25 | \fBdelete-fifo\fP 26 | \fBnew-fifo\fP 27 | \fBpurge-fifo\fP 28 | \fBread-fifo\fP 29 | \fBrewind-fifo\fP 30 | \fBwrite-fifo\fP 31 | See all 32 | \fBdocumentation\fP 33 | -------------------------------------------------------------------------------- /docs/rewind-lifo.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | rewind-lifo \- (LIFO) 4 | .SH PURPOSE 5 | Rewind LIFO list. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | rewind-lifo 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | rewind-lifo will position at the very last data element put into which was created with \fBnew-lifo\fP. Each time \fBread-lifo\fP is used, the internal position moves to the previous element in the reverse order they were put in. 19 | 20 | .SH EXAMPLES 21 | See \fBread-lifo\fP. 22 | .SH SEE ALSO 23 | LIFO 24 | 25 | \fBdelete-lifo\fP 26 | \fBnew-lifo\fP 27 | \fBpurge-lifo\fP 28 | \fBread-lifo\fP 29 | \fBrewind-lifo\fP 30 | \fBwrite-lifo\fP 31 | See all 32 | \fBdocumentation\fP 33 | -------------------------------------------------------------------------------- /docs/set-bool.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | set-bool \- (program-flow) 4 | .SH PURPOSE 5 | Set value of a boolean variable. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | set-bool [ = ] [ process-scope ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | Boolean variable is either assigned value with "=" clause, or it is assigned "false" if equal clause ("=") is omitted. 19 | 20 | If "process-scope" clause is used, then boolean is of process scope, meaning its value will persist from one request to another for the life of the process. 21 | 22 | .SH EXAMPLES 23 | Assign "true" value to boolean variable "my_bool": 24 | 25 | .RS 4 26 | .EX 27 | 28 | set-bool my_bool = true 29 | 30 | .EE 31 | .RE 32 | 33 | .SH SEE ALSO 34 | Program flow 35 | 36 | \fBbreak-loop\fP 37 | \fBcode-blocks\fP 38 | \fBcontinue-loop\fP 39 | \fBdo-once\fP 40 | \fBexit-handler\fP 41 | \fBif-defined\fP 42 | \fBif-true\fP 43 | \fBreturn-handler\fP 44 | \fBset-bool\fP 45 | \fBstart-loop\fP 46 | See all 47 | \fBdocumentation\fP 48 | -------------------------------------------------------------------------------- /docs/set-number.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | set-number \- (numbers) 4 | .SH PURPOSE 5 | Set value of a number variable. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | set-number [ = ] [ process-scope ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | Number variable is either assigned value with "=" clause, or it is assigned 0 if equal clause ("=") is omitted. 19 | 20 | If "process-scope" clause is used, then number is of process scope, meaning its value will persist from one request to another for the life of the process. 21 | 22 | Note that can also be a string character produced by using "[" and "]" to specify the index within a string (with 0 being the first character), as in: 23 | 24 | .RS 4 25 | .EX 26 | 27 | set-string my_str = "Some string" 28 | set-number my_num = my_str[2] 29 | 30 | .EE 31 | .RE 32 | 33 | In the above example, "my_num" will be 109, which is the integer representation of character 'm'. 34 | 35 | .SH EXAMPLES 36 | Initialize number "my_num" to 0 and the value of this variable, however it changes, will persist through any number of requests in the same process: 37 | 38 | .RS 4 39 | .EX 40 | 41 | set-number my_num process-scope 42 | 43 | .EE 44 | .RE 45 | 46 | Initialize number "my_num" to 10: 47 | 48 | .RS 4 49 | .EX 50 | 51 | set-number my_num = 10 52 | 53 | .EE 54 | .RE 55 | 56 | Subtract 5: 57 | 58 | .RS 4 59 | .EX 60 | 61 | set-number my_num = my_num-5 62 | 63 | .EE 64 | .RE 65 | 66 | Assign an expression: 67 | 68 | .RS 4 69 | .EX 70 | 71 | set-number my_num = (some_num*3+1)%5 72 | 73 | .EE 74 | .RE 75 | 76 | .SH SEE ALSO 77 | Numbers 78 | 79 | \fBnumber-expressions\fP 80 | \fBnumber-string\fP 81 | \fBset-number\fP 82 | \fBstring-number\fP 83 | See all 84 | \fBdocumentation\fP 85 | -------------------------------------------------------------------------------- /docs/set-param.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | set-param \- (request-data) 4 | .SH PURPOSE 5 | Set or create a parameter. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | set-param ( [ = ] ) , ... 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | set-param sets or creates parameter (see \fBget-param\fP). 19 | 20 | If parameter does not exist, it's created with . If it does exist, its value is replaced with . Note that can be of any type. 21 | 22 | If equal sign ("=") and are omitted, then is the same as , so: 23 | 24 | .RS 4 25 | .EX 26 | 27 | set-param something 28 | 29 | .EE 30 | .RE 31 | 32 | is the same as: 33 | 34 | .RS 4 35 | .EX 36 | 37 | set-param something = something 38 | 39 | .EE 40 | .RE 41 | 42 | where the first "something" is the parameter set/created, and the second "something" is an actual variable in your code. In this example, the two just happen to have the same name; this generally happens often, so this form is a shortcut for that. 43 | 44 | You can specify any number of parameters separated by a comma, for instance in this case par1 is a boolean, par2 is a number and par3 is a string: 45 | 46 | .RS 4 47 | .EX 48 | 49 | set-number par2 = 10 50 | set-param par1=true, par, par3="hi" 51 | 52 | .EE 53 | .RE 54 | 55 | 56 | .SH EXAMPLES 57 | Set the value of parameter "quantity" to "10", which is also the output: 58 | 59 | .RS 4 60 | .EX 61 | 62 | set-param quantity = "10" 63 | \[char46].. 64 | get-param quantity 65 | p-out quantity 66 | 67 | .EE 68 | .RE 69 | 70 | .SH SEE ALSO 71 | Request data 72 | 73 | \fBget-param\fP 74 | \fBrequest-body\fP 75 | \fBset-param\fP 76 | See all 77 | \fBdocumentation\fP 78 | -------------------------------------------------------------------------------- /docs/silent-header.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | silent-header \- (web) 4 | .SH PURPOSE 5 | Do not output HTTP headers. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | silent-header 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | silent-header will suppress the output of HTTP headers, such as with \fBout-header\fP, or in any other case where headers are output. The effect applies to current \fBrequest\fP only; if you use it conditionally, then you can have it on or off dynamically. 19 | 20 | If you want to suppress the headers for all \fBservice handlers\fP (as if silent-header were implied at the beginning of each), then for a \fBcommand-line\fP program, use "--silent-header" option in "gg -r" when running it; to suppress the headers in \fBservice\fPs, use "-z" option in \fBmgrg\fP. 21 | 22 | silent-header must be used prior to outputting headers, meaning either prior to any output (if out-header is not used) or prior to first out-header. 23 | 24 | There are many uses for silent-header, among them: 25 | 26 | .RS 4 27 | \[bu] 28 | A command-line program (such as a command line program) may use it to produce generic output, without any headers, 29 | 30 | .RE 31 | 32 | .RS 4 33 | \[bu] 34 | the output from a program may be redirected to a web file (such as html), in case of dynamic content that rarely changes, 35 | 36 | .RE 37 | 38 | .RS 4 39 | \[bu] 40 | a web program may output a completely different (non-HTTP) set of headers, etc. 41 | .RE 42 | 43 | 44 | .SH EXAMPLES 45 | 46 | .RS 4 47 | .EX 48 | 49 | silent-header 50 | 51 | // No headers output 52 | 53 | .EE 54 | .RE 55 | 56 | .SH SEE ALSO 57 | Web 58 | 59 | \fBcall-web\fP 60 | \fBout-header\fP 61 | \fBsend-file\fP 62 | \fBsilent-header\fP 63 | See all 64 | \fBdocumentation\fP 65 | -------------------------------------------------------------------------------- /docs/sqlite-database.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | sqlite-database \- Golf documentation (database) 4 | .SH DESCRIPTION 5 | SQLite database configuration file should contain a single line of text, and it must be the full path to the SQLite database file used, for example (if you keep it in Golf's application directory): 6 | 7 | .RS 4 8 | .EX 9 | 10 | /var/lib/gg//app/.db 11 | 12 | .EE 13 | .RE 14 | 15 | .SH SEE ALSO 16 | Database 17 | 18 | \fBbegin-transaction\fP 19 | \fBcommit-transaction\fP 20 | \fBcurrent-row\fP 21 | \fBdatabase-config-file\fP 22 | \fBdb-error\fP 23 | \fBmariadb-database\fP 24 | \fBpostgresql-database\fP 25 | \fBrollback-transaction\fP 26 | \fBrun-query\fP 27 | \fBsqlite-database\fP 28 | See all 29 | \fBdocumentation\fP 30 | -------------------------------------------------------------------------------- /docs/string-length.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | string-length \- (strings) 4 | .SH PURPOSE 5 | Get string length. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | string-length to 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | string-length will place the number of bytes in into number . 19 | 20 | Note that does not need to be null-terminated, meaning it can be a binary or text string. is the number of bytes comprising any such string. 21 | 22 | .SH EXAMPLES 23 | Variable "len" will be 6: 24 | 25 | .RS 4 26 | .EX 27 | 28 | set-string str = "string" 29 | string-length str to len 30 | 31 | .EE 32 | .RE 33 | 34 | Variable "len2" will be 18 - the string has a null character in the middle of it: 35 | 36 | .RS 4 37 | .EX 38 | 39 | set-string str2 = "string" "\ex00 after null" 40 | string-length str2 to len2 41 | 42 | .EE 43 | .RE 44 | 45 | .SH SEE ALSO 46 | Strings 47 | 48 | \fBconcatenate-strings\fP 49 | \fBcopy-string\fP 50 | \fBcount-substring\fP 51 | \fBdelete-string\fP 52 | \fBlower-string\fP 53 | \fBread-split\fP 54 | \fBreplace-string\fP 55 | \fBset-string\fP 56 | \fBsplit-string\fP 57 | \fBstring-length\fP 58 | \fBtrim-string\fP 59 | \fBupper-string\fP 60 | \fBwrite-string\fP 61 | See all 62 | \fBdocumentation\fP 63 | -------------------------------------------------------------------------------- /docs/string-number.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | string-number \- (numbers) 4 | .SH PURPOSE 5 | Convert string to number. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | string-number [ to ] \\ 13 | [ base ] \\ 14 | [ status ] 15 | 16 | .EE 17 | .RE 18 | 19 | .SH DESCRIPTION 20 | is converted to in "to" clause, using in "base" clause, where is by default either 10, or 16 (if number is prefixed with "0x" or "0X", excluding any leading minus or plus sign) or 8 (if number is prefixed with "0", excluding any leading minus or plus sign). 21 | 22 | can be between 2 and 36, inclusive. can be positive or negative (i.e. signed) and can be up to 64-bit in length. If is 0, it is the same as if it is not specified, i.e. default behavior applies. 23 | 24 | number (in "status" clause) is GG_OKAY if conversion was successful. If it wasn't successful, is 0 and is GG_ERR_OVERFLOW if represents a number that requires over 64 bits of storage, GG_ERR_INVALID if is incorrect, GG_ERR_EXIST if is empty or no digits specified. 25 | 26 | If there are trailing invalid characters (for instance "182xy" for base 10), is the result of conversion up to the first invalid character and is GG_ERR_TOO_MANY. In this example, would be 182. 27 | 28 | .SH EXAMPLES 29 | In this example, number "n" would be 49 and status "st" would be GG_OKAY: 30 | 31 | .RS 4 32 | .EX 33 | 34 | string-number "49" to n base 10 status st 35 | 36 | .EE 37 | .RE 38 | 39 | .SH SEE ALSO 40 | Numbers 41 | 42 | \fBnumber-expressions\fP 43 | \fBnumber-string\fP 44 | \fBset-number\fP 45 | \fBstring-number\fP 46 | See all 47 | \fBdocumentation\fP 48 | -------------------------------------------------------------------------------- /docs/syntax-highlighting.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | syntax-highlighting \- Golf documentation (language) 4 | .SH DESCRIPTION 5 | For syntax highlighting of Golf programs in Vim, do this once: 6 | 7 | .RS 4 8 | .EX 9 | 10 | gg -m 11 | 12 | .EE 13 | .RE 14 | 15 | The above will create a syntax file in your local Vim syntax directory: 16 | 17 | .RS 4 18 | .EX 19 | 20 | $HOME/.vim/syntax/golf.vim 21 | 22 | .EE 23 | .RE 24 | 25 | and also update your local $HOME/.vimrc file to use this syntax for files with .golf extension. All files updated are local, i.e. they affect only the current user. Each user who wants this feature must issue the above command. 26 | 27 | You can then change the color scheme to anything you like by using ":colorscheme" directly in editor, or by specifying "colorscheme" in your ".vimrc" file for a persistent change. 28 | 29 | The Golf highlighting syntax is tested with Vim 8.1. 30 | .SH SEE ALSO 31 | Language 32 | 33 | \fBinline-code\fP 34 | \fBstatements\fP 35 | \fBsyntax-highlighting\fP 36 | \fBunused-var\fP 37 | \fBvariable-scope\fP 38 | See all 39 | \fBdocumentation\fP 40 | -------------------------------------------------------------------------------- /docs/temporary-file.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | temporary-file \- Golf documentation (files) 4 | .SH DESCRIPTION 5 | To create a temporary file, use \fBuniq-file\fP with a "temporary" clause. Temporary files are the same as any other files in the \fBfile-storage\fP (and are organized in the same fashion), except that they are all under the subdirectory named "t": 6 | 7 | .RS 4 8 | .EX 9 | 10 | /var/lib/gg//app/file/t 11 | 12 | .EE 13 | .RE 14 | 15 | A temporary file is not automatically deleted - you can remove it with \fBdelete-file\fP statement when not needed (or use a periodic shell script to remove old temporary files). The reason for this is that the nature of temporary files varies, and they may not necessarily span a given time frame (such as a lifetime of a \fBrequest\fP, or a lifetime of a process that serves any number of such requests), and they may be used across number of requests for a specific purpose. Thus, it is your responsibility to remove a temporary file when it's appropriate for your application to do so. 16 | 17 | The reason for storing temporary files in a separate directory is to gain a separation of temporary files (which likely at some point can be freely deleted) from other files. 18 | 19 | See \fBuniq-file\fP for an example of creating a temporary file. 20 | .SH SEE ALSO 21 | Files 22 | 23 | \fBchange-mode\fP 24 | \fBclose-file\fP 25 | \fBcopy-file\fP 26 | \fBdelete-file\fP 27 | \fBfile-position\fP 28 | \fBfile-storage\fP 29 | \fBfile-uploading\fP 30 | \fBlock-file\fP 31 | \fBopen-file\fP 32 | \fBread-file\fP 33 | \fBread-line\fP 34 | \fBrename-file\fP 35 | \fBstat-file\fP 36 | \fBtemporary-file\fP 37 | \fBuniq-file\fP 38 | \fBunlock-file\fP 39 | \fBwrite-file\fP 40 | See all 41 | \fBdocumentation\fP 42 | -------------------------------------------------------------------------------- /docs/text-utf.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | text-utf \- (UTF) 4 | .SH PURPOSE 5 | Convert text to UTF (UTF8 or UTF16) string. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | text-utf \\ 13 | [ status ] \\ 14 | [ error-text ] 15 | 16 | .EE 17 | .RE 18 | 19 | .SH DESCRIPTION 20 | text-utf will convert string value to UTF. itself will hold the resulting UTF string. If you don't wish to be modified, make a copy of it first (see \fBcopy-string\fP). See \fButf-text\fP for the reverse conversion and data standards information. 21 | 22 | You can obtain in "status" clause. number is GG_OKAY if successful, or GG_ERR_UTF if there was an error, in which case string in "error-text" clause will contain the error message. 23 | 24 | .SH EXAMPLES 25 | 26 | .RS 4 27 | .EX 28 | 29 | // Unicode value to encode to UTF8 or UTF16 (such as \\euD834\\euDD1E as a surrogate pair) 30 | set-string txt = "\eu0459\\\[char92]"Doc\\\[char92]"\\en\\et\\eb\\ef\\er\\et\\eu21d7\\eu21d8\\et\\eu25b7\\eu25ee\\euD834\\euDD1E\\eu13eb\\eu2ca0\\eu0448\\en\\e/\\\[char92]"()\\et" 31 | 32 | // Convert to UTF 33 | text-utf txt status txt_status error-text txt_error 34 | 35 | // Expected UTF result 36 | set-string utf = "љ\[char92]"Doc\[char92]"\en\et\eb\ef\er\et⇗⇘\et▷◮𝄞ᏫⲠш\en/\[char92]"()\et" 37 | 38 | // Make sure conversion was successful 39 | if-true utf not-equal txt or txt_status not-equal GG_OKAY or txt_error not-equal "" 40 | @Error in converting string to UTF 41 | end-if 42 | 43 | .EE 44 | .RE 45 | 46 | .SH SEE ALSO 47 | UTF 48 | 49 | \fBtext-utf\fP 50 | \fButf-text\fP 51 | See all 52 | \fBdocumentation\fP 53 | -------------------------------------------------------------------------------- /docs/trim-string.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | trim-string \- (strings) 4 | .SH PURPOSE 5 | Trim a string. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | trim-string 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | trim-string trims , both on left and right. 19 | 20 | .SH EXAMPLES 21 | The variable "str" will be "some string" after trim-string: 22 | 23 | .RS 4 24 | .EX 25 | 26 | set-string str = " some string "; 27 | trim-string str 28 | 29 | .EE 30 | .RE 31 | 32 | .SH SEE ALSO 33 | Strings 34 | 35 | \fBconcatenate-strings\fP 36 | \fBcopy-string\fP 37 | \fBcount-substring\fP 38 | \fBdelete-string\fP 39 | \fBlower-string\fP 40 | \fBread-split\fP 41 | \fBreplace-string\fP 42 | \fBset-string\fP 43 | \fBsplit-string\fP 44 | \fBstring-length\fP 45 | \fBtrim-string\fP 46 | \fBupper-string\fP 47 | \fBwrite-string\fP 48 | See all 49 | \fBdocumentation\fP 50 | -------------------------------------------------------------------------------- /docs/uninstall.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | uninstall \- Golf documentation (install-golf) 4 | .SH DESCRIPTION 5 | 6 | .LP 7 | .B UNINSTALL GOLF IF INSTALLED FROM SOURCE 8 | .LP 9 | 10 | Run from command line (if you installed to a folder, add "DESTDIR=" where is the directory where it was installed): 11 | 12 | .RS 4 13 | .EX 14 | 15 | sudo make uninstall 16 | 17 | .EE 18 | .RE 19 | 20 | 21 | .LP 22 | .B UNINSTALL GOLF IF INSTALLED FROM PACKAGE 23 | .LP 24 | 25 | For Ubuntu: 26 | 27 | .RS 4 28 | .EX 29 | 30 | sudo apt remove golf 31 | 32 | .EE 33 | .RE 34 | 35 | For Redhat, Fedora and similar: 36 | 37 | .RS 4 38 | .EX 39 | 40 | sudo dnf remove golf 41 | 42 | .EE 43 | .RE 44 | 45 | For OpenSUSE: 46 | 47 | .RS 4 48 | .EX 49 | 50 | sudo zypper remove golf 51 | 52 | .EE 53 | .RE 54 | 55 | For Arch and similar: 56 | 57 | .RS 4 58 | .EX 59 | 60 | sudo pacman -R golf 61 | 62 | .EE 63 | .RE 64 | 65 | 66 | .LP 67 | .B APPLICATION FILES 68 | .LP 69 | 70 | Note that /var/lib/gg directory is not removed, as it generally contains application files. You may move such files or delete them as you see fit. 71 | .SH SEE ALSO 72 | Install golf 73 | 74 | \fBinstall-arch-manjaro\fP 75 | \fBinstall-debian\fP 76 | \fBinstall-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 77 | \fBinstall-from-source-arch-manjaro\fP 78 | \fBinstall-from-source-debian-ubuntu-raspbian\fP 79 | \fBinstall-from-source-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 80 | \fBinstall-from-source-opensuse\fP 81 | \fBinstall-in-any-folder-arch-manjaro\fP 82 | \fBinstall-in-any-folder-debian-ubuntu-raspbian\fP 83 | \fBinstall-in-any-folder-fedora-redhat-rocky-alma-centos-amazon-mageia\fP 84 | \fBinstall-in-any-folder-opensuse\fP 85 | \fBinstall-opensuse\fP 86 | \fBinstall-raspbian\fP 87 | \fBinstall-ubuntu\fP 88 | \fBuninstall\fP 89 | See all 90 | \fBdocumentation\fP 91 | -------------------------------------------------------------------------------- /docs/uniq-file.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | uniq-file \- (files) 4 | .SH PURPOSE 5 | Create a new empty file with a unique name. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | uniq-file [ temporary ] 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | One of the common tasks in many applications is creating a unique file (of any kind, including temporary). uniq-file statement does that - it creates a new unique file of zero size, with being its fully qualified name, which is always within the \fBfile-storage\fP. 19 | 20 | The file itself is created empty. If "temporary" clause is used, then the file created is a \fBtemporary-file\fP. 21 | 22 | The file has no extension. You can rename it after it has been created to reflect its usage or purpose. 23 | 24 | All files created are setup with owner and group read/write only permissions. 25 | 26 | .SH EXAMPLES 27 | The following creates an empty file with auto-generated name that will be stored in "mydoc" variable. String variable "mydoc" is defined in the statement. The string "some data" is written to a newly created file: 28 | 29 | .RS 4 30 | .EX 31 | 32 | uniq-file mydoc 33 | write-file mydoc from "some data" 34 | 35 | .EE 36 | .RE 37 | 38 | To create a temporary file: 39 | 40 | .RS 4 41 | .EX 42 | 43 | uniq-file temp_file temporary 44 | \[char46].. 45 | // use file named "temp_file" 46 | \[char46]. 47 | delete-file temp_file 48 | 49 | .EE 50 | .RE 51 | 52 | .SH SEE ALSO 53 | Files 54 | 55 | \fBchange-mode\fP 56 | \fBclose-file\fP 57 | \fBcopy-file\fP 58 | \fBdelete-file\fP 59 | \fBfile-position\fP 60 | \fBfile-storage\fP 61 | \fBfile-uploading\fP 62 | \fBlock-file\fP 63 | \fBopen-file\fP 64 | \fBread-file\fP 65 | \fBread-line\fP 66 | \fBrename-file\fP 67 | \fBstat-file\fP 68 | \fBtemporary-file\fP 69 | \fBuniq-file\fP 70 | \fBunlock-file\fP 71 | \fBwrite-file\fP 72 | See all 73 | \fBdocumentation\fP 74 | -------------------------------------------------------------------------------- /docs/unlock-file.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | unlock-file \- (files) 4 | .SH PURPOSE 5 | Unlocks file. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | unlock-file id 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | unlock-file will unlock file that was locked with \fBlock-file\fP. is the value obtained in \fBlock-file\fP's "id" clause. 19 | 20 | .SH EXAMPLES 21 | See \fBlock-file\fP. 22 | .SH SEE ALSO 23 | Files 24 | 25 | \fBchange-mode\fP 26 | \fBclose-file\fP 27 | \fBcopy-file\fP 28 | \fBdelete-file\fP 29 | \fBfile-position\fP 30 | \fBfile-storage\fP 31 | \fBfile-uploading\fP 32 | \fBlock-file\fP 33 | \fBopen-file\fP 34 | \fBread-file\fP 35 | \fBread-line\fP 36 | \fBrename-file\fP 37 | \fBstat-file\fP 38 | \fBtemporary-file\fP 39 | \fBuniq-file\fP 40 | \fBunlock-file\fP 41 | \fBwrite-file\fP 42 | See all 43 | \fBdocumentation\fP 44 | -------------------------------------------------------------------------------- /docs/unused-var.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | unused-var \- (language) 4 | .SH PURPOSE 5 | Prevent compiler error if variable is not used. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | unused-var 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | unused-var prevents \fBerroring out\fP if is unused. Generally, you don't want to have unused variables - they typically indicate bugs or clutter. However, in some cases you might need such variables as a reminder for a future enhancement, or for some other reason it is unavoidable. In any case, you can use unused-var to shield such instances from causing errors. 19 | 20 | .SH EXAMPLES 21 | In the following, variable "hw" is created and initialized. Such variable is not used at the moment, however if you would do so in the future and want to keep it, use unused-var to prevent compiler errors: 22 | 23 | .RS 4 24 | .EX 25 | 26 | set-string hw = "Hello world" 27 | unused-var hw 28 | 29 | .EE 30 | .RE 31 | 32 | .SH SEE ALSO 33 | Language 34 | 35 | \fBinline-code\fP 36 | \fBstatements\fP 37 | \fBsyntax-highlighting\fP 38 | \fBunused-var\fP 39 | \fBvariable-scope\fP 40 | See all 41 | \fBdocumentation\fP 42 | -------------------------------------------------------------------------------- /docs/upper-string.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | upper-string \- (strings) 4 | .SH PURPOSE 5 | Upper-case a string. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | upper-string 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | upper-string converts all 's characters to upper case. 19 | 20 | .SH EXAMPLES 21 | The resulting "str" is "GOOD": 22 | 23 | .RS 4 24 | .EX 25 | 26 | set-string str="good" 27 | upper-string str 28 | 29 | .EE 30 | .RE 31 | 32 | .SH SEE ALSO 33 | Strings 34 | 35 | \fBconcatenate-strings\fP 36 | \fBcopy-string\fP 37 | \fBcount-substring\fP 38 | \fBdelete-string\fP 39 | \fBlower-string\fP 40 | \fBread-split\fP 41 | \fBreplace-string\fP 42 | \fBset-string\fP 43 | \fBsplit-string\fP 44 | \fBstring-length\fP 45 | \fBtrim-string\fP 46 | \fBupper-string\fP 47 | \fBwrite-string\fP 48 | See all 49 | \fBdocumentation\fP 50 | -------------------------------------------------------------------------------- /docs/variable-scope.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | variable-scope \- Golf documentation (language) 4 | .SH DESCRIPTION 5 | Golf uses scope rules for variables that is similar to other programming languages. 6 | .SH SEE ALSO 7 | Language 8 | 9 | \fBinline-code\fP 10 | \fBstatements\fP 11 | \fBsyntax-highlighting\fP 12 | \fBunused-var\fP 13 | \fBvariable-scope\fP 14 | See all 15 | \fBdocumentation\fP 16 | -------------------------------------------------------------------------------- /docs/web-framework-for-C-programming-language.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | web-framework-for-C-programming-language \- Golf documentation (C-language) 4 | .SH DESCRIPTION 5 | 6 | .LP 7 | .B GOLF AS A WEB FRAMEWORK FOR C PROGRAMMING LANGUAGE 8 | .LP 9 | 10 | Golf source code translates to C before compilation for maximum performance; as a result, Golf offers the ability to include C code directly in extended mode (via \fBcall-extended\fP statement) which means Golf is also an effective framework for C programming language. 11 | 12 | Golf offers simple statements to perform complex common tasks, as well as memory safety. The C code that you'd include via call-extended statement may or may not be memory safe; thus once your application is in extended mode (see \fBextended-mode\fP), your application may no longer be memory safe. 13 | 14 | To make sure a Golf application is memory safe, simply search for extended-mode statement from the root source directory: 15 | 16 | .RS 4 17 | .EX 18 | 19 | find . -name "*.golf" -print -exec grep -l '^\es*extended\-mode' {} \e; 20 | 21 | .EE 22 | .RE 23 | 24 | If no matches are found, the application is memory safe. 25 | 26 | However, for applications that are written in C (for performance, access to hardware or OS features, or for any other reason), Golf offers a framework that can offload many tasks from your project, while you write C code where it's needed or necessary. 27 | 28 | The benefit is that the part of your application written in Golf (which may be a vast majority of it) offers memory safety, ease of development and maintenance, server facilities, lots of functionality, as well as high performance to begin with. Your Golf code would call your C code when needed, thus accomplishing the functionality and goals you set out to do. 29 | 30 | Just as a note of technicality, when used in extended mode, Golf is considered a framework and not a library, because Golf code will call your C code (and not the other way around). 31 | .SH SEE ALSO 32 | C language 33 | 34 | \fBcall-extended\fP 35 | \fBextended-mode\fP 36 | \fBweb-framework-for-C-programming-language\fP 37 | See all 38 | \fBdocumentation\fP 39 | -------------------------------------------------------------------------------- /docs/write-fifo.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | write-fifo \- (FIFO) 4 | .SH PURPOSE 5 | Write key/value pair into a FIFO list. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | write-fifo \\ 13 | key \\ 14 | value 15 | 16 | .EE 17 | .RE 18 | 19 | .SH DESCRIPTION 20 | write-fifo adds a pair of key/value pointers to the FIFO , specified with strings and (in "key" and "value" clauses, collectively called an "element"). 21 | 22 | It always adds elements to the end of the list. 23 | 24 | .SH EXAMPLES 25 | 26 | .RS 4 27 | .EX 28 | 29 | new-fifo nf 30 | write-fifo nf key "mykey" value "myvalue" 31 | 32 | .EE 33 | .RE 34 | 35 | .SH SEE ALSO 36 | FIFO 37 | 38 | \fBdelete-fifo\fP 39 | \fBnew-fifo\fP 40 | \fBpurge-fifo\fP 41 | \fBread-fifo\fP 42 | \fBrewind-fifo\fP 43 | \fBwrite-fifo\fP 44 | See all 45 | \fBdocumentation\fP 46 | -------------------------------------------------------------------------------- /docs/write-lifo.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | write-lifo \- (LIFO) 4 | .SH PURPOSE 5 | Write key/value pair into a LIFO list. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | write-lifo \\ 13 | key \\ 14 | value 15 | 16 | .EE 17 | .RE 18 | 19 | .SH DESCRIPTION 20 | write-lifo adds a pair of key/value to the LIFO , specified with strings and (in "key" and "value" clauses, collectively called an "element"). 21 | 22 | It always adds an element so that the last one written to would be the first to be read with \fBread-lifo\fP. 23 | 24 | .SH EXAMPLES 25 | 26 | .RS 4 27 | .EX 28 | 29 | new-lifo nf 30 | write-lifo nf key "mykey" value "myvalue" 31 | 32 | .EE 33 | .RE 34 | 35 | .SH SEE ALSO 36 | LIFO 37 | 38 | \fBdelete-lifo\fP 39 | \fBnew-lifo\fP 40 | \fBpurge-lifo\fP 41 | \fBread-lifo\fP 42 | \fBrewind-lifo\fP 43 | \fBwrite-lifo\fP 44 | See all 45 | \fBdocumentation\fP 46 | -------------------------------------------------------------------------------- /docs/write-message.2gg: -------------------------------------------------------------------------------- 1 | .TH GOLF 2gg $VERSION $DATE Development Tools 2 | .SH NAME 3 | write-message \- (messages) 4 | .SH PURPOSE 5 | Write key/value to a message. 6 | 7 | .SH SYNTAX 8 | 9 | .RS 4 10 | .EX 11 | 12 | write-message key value 13 | 14 | .EE 15 | .RE 16 | 17 | .SH DESCRIPTION 18 | write-message will append to a key/value pair, in the form of string (in "key" clause) and string (in "value" clause). 19 | 20 | must have been created with \fBnew-message\fP. In order to use write-message, a message must not have been read from (see \fBread-message\fP). 21 | 22 | .SH EXAMPLES 23 | 24 | .RS 4 25 | .EX 26 | 27 | new-message msg 28 | write-message msg key "key1" value "value1" 29 | 30 | .EE 31 | .RE 32 | 33 | .SH SEE ALSO 34 | Messages 35 | 36 | \fBget-message\fP 37 | \fBnew-message\fP 38 | \fBread-message\fP 39 | \fBSEMI\fP 40 | \fBwrite-message\fP 41 | See all 42 | \fBdocumentation\fP 43 | -------------------------------------------------------------------------------- /gg.te: -------------------------------------------------------------------------------- 1 | #SPDX-License-Identifier: Apache-2.0 2 | #Copyright 2018-2025 Gliim LLC. 3 | #Licensed under Apache License v2. See LICENSE file. 4 | #On the web http://golf-lang.com/ - this file is part of Golf framework. 5 | 6 | policy_module(gg, 2.0.0) 7 | 8 | ######################################## 9 | # 10 | # Declarations 11 | # 12 | 13 | #create gg file type 14 | type ggfile_t; 15 | files_type(ggfile_t); 16 | 17 | 18 | #create gg execute type 19 | type gg_t; 20 | domain_type(gg_t) 21 | 22 | #create fcgi port type for golf 23 | type ggport_t; 24 | corenet_port(ggport_t) 25 | 26 | #make execute type be the same as unconfined_t 27 | optional_policy(` 28 | unconfined_domain(gg_t) 29 | ') 30 | 31 | require { 32 | type unconfined_t; 33 | role unconfined_r; 34 | } 35 | 36 | #add to unconfine role 37 | role unconfined_r types gg_t; 38 | #set transition on execution of ggfile_t (by the unconfined process) to gg_t type 39 | type_transition unconfined_t ggfile_t : process gg_t; 40 | #allow transition from unconfined to gg_t 41 | allow unconfined_t gg_t : process transition; 42 | #allow execution of ggfile_t by the unconfined (which will then transion as above) 43 | allow unconfined_t ggfile_t : file { execute read getattr }; 44 | #allow gg_t process domain to actually execute the ggfile_t 45 | allow gg_t ggfile_t : file { ioctl read getattr lock execute execute_no_trans entrypoint open} ; 46 | #allow golf port to bind 47 | allow gg_t ggport_t:tcp_socket { connect bind name_bind accept listen}; 48 | 49 | -------------------------------------------------------------------------------- /golf.sel: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #SPDX-License-Identifier: Apache-2.0 3 | #Copyright 2018-2025 Gliim LLC. 4 | #Licensed under Apache License v2. See LICENSE file. 5 | #On the web http://golf-lang.com/ - this file is part of Golf framework. 6 | 7 | #generate SELinux policies 8 | 9 | #$1 is lib dir, $2 is data dir, $3 is bindir 10 | 11 | LIBDIR="$1" 12 | SELINUXDIR="$2" 13 | ROOTDIR="$3" 14 | 15 | cd $LIBDIR 16 | mkdir -p $LIBDIR/tmp 17 | cp -f gg.te golf.te $LIBDIR/tmp/ 18 | cd $LIBDIR/tmp 19 | make -f /usr/share/selinux/devel/Makefile gg.pp 20 | install -D -m 0600 gg.pp -t $SELINUXDIR/selinux/packages/ 21 | checkmodule -M -m -o golf.mod golf.te 22 | semodule_package -o golf.pp -m golf.mod 23 | install -D -m 0600 golf.pp -t $SELINUXDIR/selinux/packages/ ; 24 | 25 | if (( $EUID == 0 )); then 26 | semodule -n -i "$SELINUXDIR/selinux/packages/gg.pp" 27 | semodule -n -i "$SELINUXDIR/selinux/packages/golf.pp" 28 | fi 29 | 30 | if [ -d "$ROOTDIR/var/lib/gg" ]; then 31 | if /usr/sbin/selinuxenabled ; then 32 | if (( $EUID == 0 )); then 33 | load_policy 34 | #set file types here, .fc setting won't work 35 | sudo semanage fcontext -a -t ggfile_t "$ROOTDIR/var/lib/gg(/.*)?" 36 | restorecon -R $ROOTDIR/var/lib/gg 37 | sudo semanage fcontext -a -t ggfile_t "$ROOTDIR/usr/bin/mgrg" 38 | restorecon $ROOTDIR/usr/bin/mgrg 39 | fi 40 | fi 41 | fi 42 | 43 | cd $LIBDIR 44 | rm -rf $LIBDIR/tmp 45 | -------------------------------------------------------------------------------- /golf.te: -------------------------------------------------------------------------------- 1 | #SPDX-License-Identifier: Apache-2.0 2 | #Copyright 2018-2025 Gliim LLC. 3 | #Licensed under Apache License v2. See LICENSE file. 4 | #On the web http://golf-lang.com/ - this file is part of Golf framework. 5 | 6 | module golf 1.0; 7 | 8 | require { 9 | type httpd_t; 10 | type ggfile_t; 11 | type gg_t; 12 | type ggport_t; 13 | type unconfined_t; 14 | class sock_file write; 15 | class unix_stream_socket connectto; 16 | type unreserved_port_t; 17 | class tcp_socket { name_bind name_connect }; 18 | } 19 | 20 | 21 | 22 | #allow web server to connect to gg_t golf process 23 | allow httpd_t gg_t:unix_stream_socket connectto; 24 | #allow web server to write to golf socket (must also be allow by DAC, which sockets are, but nothing else) 25 | allow httpd_t ggfile_t:sock_file write; 26 | #allow web server to connect to golf processes only 27 | allow httpd_t ggport_t:tcp_socket name_connect; 28 | -------------------------------------------------------------------------------- /pks: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: Apache-2.0 3 | # Copyright 2018-2025 Gliim LLC. 4 | # Licensed under Apache License v2. See LICENSE file. 5 | # On the web http://golf-lang.github.io/ - this file is part of Gliim framework. 6 | 7 | #./pks [git-pwd] 8 | # git-pwd is to run it non-interactively 9 | 10 | # 11 | #Do NOT run this script unless you are upstream developer! Internal use only. 12 | # 13 | #get the part that deals with signing of packages,changelog and version for the 14 | #official Gliim release. 15 | # 16 | 17 | set -eE -o functrace 18 | trap 'echo "Error: status $?, $(caller), line ${LINENO}"' ERR 19 | 20 | if [ ! -d "$(pwd)/rv" ]; then 21 | rm -rf rv 22 | mkdir -p rv 23 | cd rv 24 | if [ "$1" != "" ]; then 25 | git clone https://gliim:$1@bitbucket.org/gliim/private_golf.git . 26 | else 27 | git clone https://gliim@bitbucket.org/gliim/private_golf.git . 28 | fi 29 | cd .. 30 | fi 31 | 32 | rv/pks 33 | -------------------------------------------------------------------------------- /stub_after.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | // Copyright 2018-2025 Gliim LLC. 3 | // Licensed under Apache License v2. See LICENSE file. 4 | // On the web http://golf-lang.com/ - this file is part of Golf framework. 5 | 6 | 7 | // 8 | // Stub implementation of after-service event, overriden by the actual implementation in after-handler.golf 9 | // 10 | 11 | #include "golf.h" 12 | 13 | 14 | void after_handler () 15 | { 16 | GG_TRACE(""); 17 | } 18 | 19 | 20 | -------------------------------------------------------------------------------- /stub_before.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | // Copyright 2018-2025 Gliim LLC. 3 | // Licensed under Apache License v2. See LICENSE file. 4 | // On the web http://golf-lang.com/ - this file is part of Golf framework. 5 | 6 | 7 | // 8 | // Stub implementation of before-service event, overriden by the actual implementation in before-handler.golf 9 | // 10 | 11 | #include "golf.h" 12 | 13 | 14 | void before_handler () 15 | { 16 | GG_TRACE(""); 17 | } 18 | 19 | 20 | -------------------------------------------------------------------------------- /sys: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #SPDX-License-Identifier: Apache-2.0 3 | #Copyright 2018-2025 Gliim LLC. 4 | #Licensed under Apache License v2. See LICENSE file. 5 | #On the web http://golf-lang.com/ - this file is part of Golf framework. 6 | 7 | 8 | # Set variables for building and installing a Golf application. 9 | # If your system doesn't conform, you can change these variables to fit 10 | 11 | function lowest_version() { 12 | echo "$@" | sed 's/ /\n/g'| sort -V | head -n 1 13 | } 14 | 15 | #utility to check for versions matching 16 | if [ "$1" == "greater_than_eq" ]; then 17 | L=$(lowest_version "$2" "$3" ) 18 | if [ "$L" == "$3" ]; then echo "1"; else echo "0"; fi 19 | exit 0 20 | fi 21 | 22 | #do not do all twice if already done 23 | if [ "$GG_SYSTEM_DONE" != "1" ]; then 24 | 25 | #determine operating system, some don't have /etc/os-release (or it isn't linked), try the alternative 26 | if [ -f "/etc/os-release" ]; then 27 | . /etc/os-release 28 | elif [ -f "/usr/lib/os-release" ]; then 29 | . /usr/lib/os-release 30 | elif [ -f "/etc/lsb-release" ]; then 31 | #check if lsb-release present, and use it to override os-release, as it is generally more accurate 32 | . /etc/lsb-release 33 | else 34 | ID="unknown" 35 | VERSION_ID="unknown" 36 | fi 37 | export GG_PLATFORM_ID="$ID" 38 | export GG_PLATFORM_VERSION="$VERSION_ID" 39 | 40 | 41 | #the following three should not be changed manually, make tools set them 42 | export GG_LIBRARY_PATH=/usr/lib/golf 43 | export GG_INCLUDE_PATH=/usr/include/golf 44 | export GG_VERSION=100.100 45 | 46 | #do not execute again if already done 47 | export GG_SYSTEM_DONE=1 48 | fi 49 | 50 | 51 | # 52 | # 53 | # 54 | #From here on, only system requests are allowed, each exiting with 'exit' 55 | # 56 | # 57 | # 58 | 59 | if [ "$1" == "pgconf" ]; then 60 | ECODE="0" 61 | which pg_config 2>/dev/null 1>/dev/null || ECODE=$? 62 | if [ "$ECODE" == "0" ]; then 63 | echo "yes" 64 | else 65 | echo "no" 66 | fi 67 | exit 0 68 | fi 69 | 70 | if [ "$1" == "showid" ]; then 71 | echo $GG_PLATFORM_ID 72 | exit 0 73 | fi 74 | 75 | 76 | 77 | 78 | --------------------------------------------------------------------------------