Category Archives: workday

go: Enumeration

There is no enumeration in Golang, but here is an example, which could be good start for any project, which needs to utilize enumeration. See https://play.golang.org/p/pD29UI37iq1

Posted in golang, workday | Leave a comment

go: Three dots/ellipses notation and variadic function; arrays vs slices

Go program example below explores arrays, slices and three dots notation. Arrays and slices are similar, arrays have static usage, slices are dynamic. Arrays are type values, fixed length sentences of items of the same type. Slices are reference types. … Continue reading

Posted in golang, workday | Leave a comment

go: Concurrent records processing with channels

Let’s say we have list of records, which can be processed concurrently. Processing time can be different. In example below processing time depends on two parameters. There are used non buffered input and output channels.  There are these steps: Submitting … Continue reading

Posted in golang, workday | Leave a comment

go: base64 decoding

Here is an example how to decode base64 encoded strings https://play.golang.org/p/iojjUKwvZvn It uses encoding packages encoding/base64 and encoding/hex . package main import ( “fmt” “encoding/base64” “encoding/hex” ) func isAscii7printable(bytes []byte)(bool){ for _, b := range bytes { if b < … Continue reading

Posted in golang, workday | Leave a comment

go: characters frequency

Let’s explore characters frequency in the go string. Characters in go are in the format int32 – rune, and they can have any unicode value. Here is a simple go program https://play.golang.org/p/fbg7VXetxCg . package main import ( “fmt” “sort” ) … Continue reading

Posted in golang, workday | Leave a comment

go: duration loop

Here is a simple duration loop go program https://play.golang.org/p/ly9U9EUr2of package main import ( “fmt” “time” ) func main() { duration := time.Second *10 fmt.Println(“Hello, duration loop “+duration.String()+” long”) t1 := time.Now() for t2:= time.Now(); t2.Sub(t1) < duration; t2 = time.Now(){ … Continue reading

Posted in golang, workday | Leave a comment

go: proverbs

Rob Pike at Gopherfest on November 18, 2015 mentioned several thoughtful go proverbs, as you may see on this video. Here they are: Don’t communicate by sharing memory, share memory by communicating. Concurrency is not parallelism. Channels orchestrate; mutexes serialize. … Continue reading

Posted in golang, workday | Leave a comment

go: printing struct & array

Printing struct https://play.golang.org/p/BvMIqF3Pmc9 package main import “fmt” type point struct { x, y int } func main() { p := point{1, 2} fmt.Println(“Printing struct point:”) fmt.Printf(” type %%T: %T\n”, p) fmt.Printf(” just values %%v: %v\n”, p) fmt.Printf(” +field names %%+v: … Continue reading

Posted in golang, workday | Leave a comment

go: add elements to array

Here is one way, how to add elements to array in go language, see https://play.golang.org/p/nCLX23ymRUM package main import ( “fmt” ) type MyRecord struct { Name string Phone string } var recA = MyRecord{Name: “Anna”, Phone: “123”} var recB = … Continue reading

Posted in golang, workday | Leave a comment

GIMP: first script-fu

GIMP is great tool for images manipulation. Even better is to automate as much as possible through scripts. Lets say we would create file named my-first.scm and this file will be placed into sub-directory scripts. Location would depend on the … Continue reading

Posted in workday | Leave a comment