Category Archives: Go (en)

Disable Go language telemetry

It turns out, Go (specifically gopls aka the local language server) collects telemetry, the scoundrel. Gathering some kind of anonymous data on how we code. How to disable it: C:\Users<user>\AppData\Roaming\go\telemetry create a file there named mode (without an extension!) inside … Continue reading

Posted in Go (en) | Leave a comment

Go language. About runes (data type), PostgreSQL and JS

If you are making a Go network application that works with databases and/or javascript, you need to be careful when using the rune data type. For example, PostgreSQL does not have a data type that matches rune; There are options … Continue reading

Posted in Go (en) | Leave a comment

Golang. Sum of consecutive numbers

The problem is to find in an array of integers a sequence of consecutive numbers whose sum is equal to n. Our program will read a list of integers (e.g., 5 2 3 4 6 1 4 10 1), followed … Continue reading

Posted in Go (en) | Leave a comment

Go Language. Map Exercise

Based on the list of dungeon raids, find the top player in the guild 🙂  Example of input:

Posted in Go (en) | Leave a comment

Golang. Exercises for slices

Let’s look at some examples of slice programs in Go. First one… The user enters two rows of numbers. Our task is to collect them in one slice, removing duplicates. As an exercise, we will not use cards, but ordinary … Continue reading

Posted in Go (en) | Leave a comment

Golang. Selection Sort

Selection sort is a simple sorting algorithm that repeatedly selects the minimum item from the unsorted part of the list and swaps it with the first unsorted item. Example code in Go:

Posted in Go (en) | Leave a comment

Golang. Bubble sorting

О… how much is in this “Chink”-sound!.. We learned to sort by “bubble” back in school (hello, Mr.Obama!). Why not make a code for this sorting in Go? 😀 Even if it is seldom useful, it’s a good exercise for … Continue reading

Posted in Go (en) | Leave a comment

Golang. Fisher-Yates algorithm

The user enters any number, letter, word, or whatever he wants, separated by a space. Let’s say he even enters card values (poker hand), such as A 3 J Q 10. Our job is to shuffle these cards. To do … Continue reading

Posted in Go (en) | Leave a comment

Golang. Console calculator

Let’s write a simple console calculator that performs basic arithmetic operations. First, we give it the numbers with which we want to perform operations using the add <number> command (we can give several numbers). Then we can use the commands … Continue reading

Posted in Go (en) | Leave a comment

Golang. Interfaces

The most cumbersome for newcomers to golang are the interfaces. Here are some examples of code I took apart to “smoke” them, I hope they will help you too. The idea is to look at the code, then close it … Continue reading

Posted in Go (en) | Leave a comment

Golang. Closures and Fibonacci Numbers

Assignment number 26 in the Go Tour. Implement a Fibonacci function that returns a function (closure) that returns consecutive Fibonacci numbers (0, 1, 1, 1, 2, 3, 5, …). Solution:

Posted in Go (en) | Leave a comment

Golang. Exercise: Maps

So, there we have exercise 23 from Go Tour. Implement the WordCount function. It should return a map (data type map) of the counts of each “word” in the string s. The function wc.Test runs a set of tests against … Continue reading

Posted in Go (en) | Leave a comment

Golang. Two-dimensional slices (2D)

From chapter 18 of Go tour.. In general, the tasks in this ‘tour’ are quite itchy B) So… Implement the Pic function. It should return a fragment of length dy, each element of which is a fragment of dx 8-bit … Continue reading

Posted in Go (en) | Leave a comment

Golang. Point belong to the circle?

The last example on Pythagoras’ theorem is quite simple. Let’s take a problem from the same topic, but more complicated. Suppose we have a circle in the center of x-axis and y-axis (i.e. center at coordinates 0,0). Let’s write a … Continue reading

Posted in Go (en) | Leave a comment

Golang. Pythagoras Theorem

Continue practicing Go and remembering the school curriculum “Pythagoras pants are equal on all sides!” Or to paraphrase in a more boring version: the square of the length of the hypotenuse of a right triangle is equal to the sum … Continue reading

Posted in Go (en) | Leave a comment

Golang. Character string into a numeric slice

Let’s write a simple program in Go that will take a string, break it down into slice elements, and convert each element into a number. First, all the code, and I will break it down in detail below:

Posted in Go (en) | Leave a comment

Golang. Number into words

Let’s write a program that prints numbers as text. Let’s limit it to a range of 1 to 1000. Here is the first example of code, a fuzzy one:

Posted in Go (en) | Leave a comment