# Category Archives: Go (en)

## 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

## 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

## Go Language. Map Exercise

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

## 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

## 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:

## 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

## 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

## 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

## 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

## 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:

## 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

## 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

## 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

## 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

## 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:

## 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:

## Golang: Newton’s algorithm

Task number 8 in golang tour… Cycles and functions To play with functions and loops, let’s implement the square root function: Given a number x, we want to find the number z for which z² is closest to x. Computers … Continue reading