Skip to content

natejenson/learn-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Learning Go

A collection of various examples of the Go Programming Language.

Trying It

Most of the examples (with the exception of the unit tests) can be run via go run, eg. go run slices/leftrotation.go.

Topics

Slices

  • leftrotation.go demostrates two algorithms for rotating an array (or slice, in this case) to the left by an abitrary number of positions. See the /slices directory for more examples with slices.

Bitwise operators

  • parity.go determines the parity of the given integer, returning 1 if the number of ones in the binary string is odd, other wise 0 if even. See the /bits directory for more bitwise stuff.

Maps

  • twosum.go uses a map to solve the two-sum problem, which is to find which two (if any) numbers in an array sum up to the given total. See the /maps directory for more map shenanigans.

Strings

Structs & Interfaces

Goroutines

  • race.go will spawn a handful of goroutines to show how concurrency is handled in go. See the /goroutines directory for more.

Channels

  • sync.go uses goroutines and channels to wait for responses from two (simulated) external dependencies. See the /channels directory for more on how to use channels in Go.

Unit tests

  • sum_test.go demostrates a simple unit test suite. First cd tests, then run go test to run the test file in that directory. Optionally, add the -v flag at the end to get a verbose pass/fail message for each test.

About

A collection of examples to help anyone start learning Go. 🎓

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages