Category: Go (Golang)

Go (Golang) is a new and growing language from Google. It was developed as a language for creating high-performance programs running on distributed systems and multi-core processors.

We publish articles about intricacies of practical use of the Go language in terms of large commercial projects.

Distinctive features

Go has common features with C, C ++ and C #. It provides full support for work with pointers, like C / C ++. At the same time, arithmetic operations with pointers that can be sometimes leading to errors when using C / C ++ are not implemented. A so-called Go-routine and channels are something like a business card of this language.

Go-routines and channels

Go routine is a function that is called asynchronously (in another thread) and is executed concurrently with other functions. Channels are used for data exchange between Go-routines. Channels can also be used to synchronize Go-Routines with each other and with the procedure that started them. A select operator, (an analog of switch in C and C ++ programming languages) is used for work with channels. It is possible to create channels with buffering.

String transfer from a function in GO to a code in C without memory allocation (Part 2)

We were discussing a possibility of string transfer without memory allocation in the previous article. Attempts to use this method in the real projects revealed that there are cases when this method is not applicable. Everything is working just fine if a string object is constructed from a static string constant or by means of

String transfer from a function in GO to a code on C without memory allocation (Part 1)

CGO documentation illuminates string transfer issue rather poorly. They only mention that C.CString() function should be used in order to convert a string object into a pointer to a buffer with a zero-terminated string – char*, which is coherent for the C code. This is great; however, a memory block is being allocated during this procedure