Go for Java Developer Labs
As part of the NFJS virual workshop series, this repository is the labs for Go for Java developer workshop
This is a series of 7 labs (each one building on the last one), built to solidify the course concepts AND to provide real world insights.
Demos for the class can be found at: https://github.com/kensipe/golang-demos-nfjs
Requirements
- Go 1.18 (Go 1.13+ is the base requirement for these labs)
- git
- apikey from https://openweathermap.org/api
- Go Editor. If new we recommend VSCode and/or Goland
make
- Projects are built withmake
. We can work around for non-make users.
Please get the apikey early in the course as provisioning a key can take time.
Solutions at: https://github.com/codementor/wman/ with solution branches for each lab.
Go Project Setup and Layout
Lab 1:In this lab you will become familar with Go; go run, go build, go test and the Go environment. In the end, you will understand the project structure for a Go project.
- Go run, Go doc, Go build
- Go project Makefile
- Go linting introduction
- Go Project structure
Functions, data structures and tests
Lab 2:Starting with lab 1 and using information we learned, this lab you will create a function in a package under pkg
, create a test for it and use it from the main client app.
- packages and imports
- creating code within a package
- writing and running a go test
- data structure constraints between bytes and runes
Go Module Dependencies and Cobra CLI
Lab 3:In this lab you will become familar with Go dependencies using them to create a better command-line.
- Go dependencies
- Cobra CLI
Starting with lab 2, this lab we will add a dependency to the project using a tool known for better commandline development called Cobra.
Note: This lab assumes you have a solution for lab 2 as a starting point
Data Conversion, Linting, Build Tags
Lab 4:Starting with lab 3, we will extend a command to calculate dog years. In the process we will need to convert strings to int and back. We will work with STDIN for input and provide error handling. Then we will take a deeper look at linting.
- STDIN
- error handling
- data conversions
- linting
- build tags
- variable tests
Note: This lab assumes you have a solution for lab 3 as a starting point.
JSON Decoding to Data Structures and working with Files
Lab 5:In this lab you will become familar with Go struct and methods, along with working with dependencies.
- Structs
- JSON Encoding / Decoding
- Files
Note: This lab assumes you have a solution for lab 3 as a starting point.
HTTP Requests to Go Data Structs
Lab 6:In this lab you will level up on Go structs and our use of Cobra CLI, along with learning how to make HTTP Get requests.
- Structs
- JSON Encoding / Decoding
- HTTP Requests
- UITable
Note: This lab assumes you have a solution for lab 5 as a starting point.
Lab 7: Go Routines and Channels
In this lab you will reinforce learning around goroutines and channels making concurrent HTTP requests.
- struct sorting
- go routines
- channels
- sync.WaitGroup
Note: This lab assumes you have a solution for lab 6 as a starting point.