- Fixed issues with SELinux where security policy wouldn't be set correctly.
- Removed Arch from the list of distros.
- Rearranged methods of installation to allow direct installation using apt and dnf.
- Removed lintian errors and warnings
Monday, March 31, 2025
Golf 373 released
Saturday, March 29, 2025
FIFO in Golf
Golf has built-in FIFO list type. You can create a FIFO variable and then store key/value string pairs in it, which you can then read back in the order you put them in. You can also rewind the FIFO list and obtain the same key/value pairs over and over again if needed.
This is an example of FIFO list usage. This small command-line application will store key/value pairs "key1"/"value1" and "key2"/"value2" and then obtain them twice.
First, let's create a directory for our application:
And then create the application itself:
Copy and paste the Golf code below to file "list.golf":
This is an example of FIFO list usage. This small command-line application will store key/value pairs "key1"/"value1" and "key2"/"value2" and then obtain them twice.
First, let's create a directory for our application:
mkdir test-list cd test-list/Copied!

And then create the application itself:
gg -k list-app
Copied!

Copy and paste the Golf code below to file "list.golf":
begin-handler /list silent-header // Create a list new-fifo mylist // Add data to the list write-fifo mylist key "key1" value "value1" write-fifo mylist key "key2" value "value2" start-loop // Get data from the list read-fifo mylist key k value v status st // Check if no more data if-true st not-equal GG_OKAY break-loop end-if @Obtained key <<print-out k>> with value <<print-out v>> end-loop // Go through the list again, use rewind-fifo for that rewind-fifo mylist start-loop read-fifo mylist key k value v status st if-true st not-equal GG_OKAY break-loop end-if @Again obtained key <<print-out k>> with value <<print-out v>> end-loop // Delete FIFO list purge-fifo mylist end-handlerCopied!

Sunday, March 23, 2025
How to debug Golf programs with gdb
Starting with Golf 513, debugging information is always included, be it in debug packages, or when compiling from source. You can compile your Golf application normally:
This will create an executable that can be debugged with gdb. You can debug your Golf program with gdb just as if it were a plain C program, which technically it is. This makes it much easier to get to the bottom of any issue directly without having to deal with virtual machines, p-code translation, assembler etc.
For this reason, the debugging ecosystem for Golf programs is already fully developed. For instance you can use Valgrind or Google ASAN with Golf programs just as you'd with a C program.
Note that in order to debug the Golf itself, it's best to be compiled from source, or you need to use the included debugging information (meaning you need to install a debug package). This will be covered in another article here on Golf blog.
Here's an example of debugging using Golf. We'll create a little parsing application to illustrate.
First, let's create a directory for our application "split" (since you'll be splitting a URL query string into name/value pairs):
Create a source file "parse.golf" and copy this:
This program will parse the string "a=1&b=2&c=3" to produce name/value pairs - this is obviously a parsing of URL query string. It uses split-string statement which will split the string based on some delimiter string, and then you use read-split statement to get the split pieces one by one. Very simple.
gg -q
Copied!

This will create an executable that can be debugged with gdb. You can debug your Golf program with gdb just as if it were a plain C program, which technically it is. This makes it much easier to get to the bottom of any issue directly without having to deal with virtual machines, p-code translation, assembler etc.
For this reason, the debugging ecosystem for Golf programs is already fully developed. For instance you can use Valgrind or Google ASAN with Golf programs just as you'd with a C program.
Note that in order to debug the Golf itself, it's best to be compiled from source, or you need to use the included debugging information (meaning you need to install a debug package). This will be covered in another article here on Golf blog.
Here's an example of debugging using Golf. We'll create a little parsing application to illustrate.
First, let's create a directory for our application "split" (since you'll be splitting a URL query string into name/value pairs):
mkdir split cd split gg -k splitCopied!

Create a source file "parse.golf" and copy this:
begin-handler /parse silent-header set-string str = "a=1&b=2&c=3" // Split string using "&" as a delimiter split-string str with "&" to pair count pair_tot start-loop repeat pair_tot use pair_count read-split pair_count from pair to item // Now split each item using "=" as a delimiter split-string item with "=" to equal read-split 1 from equal to name read-split 2 from equal to value // Output each name/value print-format "Name [%s] value [%s]\n", name, value end-loop end-handlerCopied!

This program will parse the string "a=1&b=2&c=3" to produce name/value pairs - this is obviously a parsing of URL query string. It uses split-string statement which will split the string based on some delimiter string, and then you use read-split statement to get the split pieces one by one. Very simple.
Wednesday, March 19, 2025
Maximum file size uploaded to Golf server
By default, maximum file size you can upload to Golf application server is about 25MB. You can change that by using "--maxupload" option in gg command line utility when you build your application:
gg -q --maxupload=100000000
In this case, maximum size of an uploaded file is about 100MB.
In order to know in your application (at run-time) what is this limit, use get-app:
get-app upload-size to up_size
print-format "Upload size is %ld\n", up_size
For an example of uploading files, see file manager example.
Sunday, March 16, 2025
Golf 324 released
These changes do not affect functionality, nor they fix any bugs. They are related to packaging of Golf, making it more compliant and smaller. They also allow debugging of production issues with the inclusion of debugging symbols, without compromising the performance.
- Changes to debian packaging and build process to get a clean lintian check.
- Removed HTML documentation from the installation packages, since man pages included cover it entirely, and the web pages are available on the web for viewing or download (see also single page documentation).
- Debugging (.dbg) files are now included in all builds (in debian as a separate package, in others as debugging symbols files included in the package).
- For manual install, stripping of all executables and libraries is done, along with creation of .dbg (debug symbol) files, to be used in debugging with gdb (as core or addr2line). Note this is also done for any other packaging (rpm, zypper, pacman).
Tuesday, March 11, 2025
Golf 297 released
- Fixed bug where Golf build fails with libxml2 errors on some platforms. The issues comes from libxml2 changing const-ness of its error handling function at some point.
Golf 295 released
- Fixed fedora.spec build file for Fedora/RedHat/OpenSuse/Mageia/Amazon Linux etc. Previous release removed some unnecessary files for regex feature, and that broke the COPR build for these platforms. This fix is to have a successful build.
Monday, March 10, 2025
Golf 288 released
This is a major Golf release. First and foremost, it adds XML support. Read below for any other changes that may affect you.
- Added XML support. See xml-doc and read-xml statements for parsing and using XML documents.
- Changed statements and clauses that use "utf8" to simply use "utf". The reason is that Golf supports both UTF8 and UTF16 already, and stating just "utf8" doesn't reflect that. Statements "text-utf8" and "utf8-text" are renamed to "text-utf" and "utf-text". These statements allow conversion from Unicode to UTF and back. In addition, "utf8" clause of "match-regex" is now simply "utf".
- When using MariaDB, the connection will
How to know Golf version
To get Golf version, use "-v" flag to gg utility:
gg -v
It might produce something like this, showing Golf version (in this case 285) and Operating System version it's running on (in this case Ubuntu 24):
Golf 285 on ubuntu (24)
...
Sunday, March 2, 2025
Golf 273 released
- Fixed two bugs that prevented compilation of Golf program in some cases. The issues were introduced in version 265.
- Set proper permissions on pcre2* files for packaging
Saturday, March 1, 2025
Web framework for C programming language
Golf has an "extended" mode, which allows for C code to be used directly. Normally, this is not allowed, but if you use extended-mode statement in your .golf file, then you can call C code from it.
In extended mode, Golf is effectively a web framework for C programming language; read this for more about implications on memory safety.
Here's the example of using Golf as a web framework for C. In this case it's a simple C function to calculate the factorial of a a number. Then we'll expose this functionality in an equally simple web application.
Create "fact" application ("-k"):
Save the following into a file "calc-fact.golf". This is the web service which will interact with web clients (such as browsers); it will also call the C function we'll create a bit further below:
In extended mode, Golf is effectively a web framework for C programming language; read this for more about implications on memory safety.
Here's the example of using Golf as a web framework for C. In this case it's a simple C function to calculate the factorial of a a number. Then we'll expose this functionality in an equally simple web application.
mkdir -p c-for-web cd c-for-webCopied!

Create "fact" application ("-k"):
gg -k fact
Copied!

Save the following into a file "calc-fact.golf". This is the web service which will interact with web clients (such as browsers); it will also call the C function we'll create a bit further below:
extended-mode // extended mode in order to call C code %% /calc-fact public get-param par // get input parameter from URL string-number par to num // convert to number set-number result call-extended factorial(num, &result) // call C function // Output result @Factorial of <<print-out par>> is <<print-out result>> %%Copied!

Subscribe to:
Posts (Atom)