-
Archives
- January 2023
- December 2022
- November 2022
- October 2022
- April 2022
- January 2022
- December 2021
- November 2021
- February 2021
- January 2021
- December 2020
- September 2020
- August 2020
- July 2020
- June 2020
- January 2020
- December 2019
- September 2019
- July 2019
- March 2019
- February 2019
- January 2019
- December 2018
- November 2018
- August 2018
- June 2018
- February 2018
- January 2018
- October 2017
- September 2017
- August 2017
- April 2017
- March 2017
- January 2017
- November 2016
- October 2016
- September 2016
- May 2016
- February 2016
- January 2016
- December 2015
- August 2015
- July 2015
- April 2015
- February 2015
- December 2014
- October 2014
- September 2014
- August 2014
- July 2014
- June 2014
- May 2014
- March 2014
- October 2013
- June 2013
- May 2013
- April 2013
- July 2012
- June 2012
- April 2012
- January 2012
- December 2011
- November 2011
- October 2011
- June 2011
- May 2011
- March 2011
- February 2011
- January 2011
- December 2010
- November 2010
- October 2010
- August 2010
- June 2010
- May 2010
- April 2010
- January 2010
- October 2009
- September 2009
- July 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
-
Meta
Category Archives: golang
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
go: interface example
Go is fresh fast relatively new language. One of the key to utilize it’s power are interfaces. Here is example of the geometry interfaces. See https://play.golang.org/p/nQ_ylb2jXKS package main import ( “fmt” “math” ) //https://www.mathsisfun.com/area.html type geometry interface { area() float64 … Continue reading
Posted in golang, workday
Leave a comment