AlexGalhardo / learning-go

Repository to save my Go programming language studies notes and references.

Repository from Github https://github.comAlexGalhardo/learning-goRepository from Github https://github.comAlexGalhardo/learning-go

Introduction

  • Repository to save my Go programming language studies notes and references.

Install

Tools

Libs and Frameworks

Online Courses

Articles

Books

Github

Cheat Sheet CLI commands

Module Management

  • Initialize a new module
go mod init <module-name>
  • Add dependencies
go get <package>
  • Update dependencies
go get -u <package>
  • Update dependencies and show details
go get -u -v <package>
  • Organize the go.mod file
go mod tidy
  • Check module consistency
go mod verify
  • Show module dependencies
go list -m all

Compiling and Running

  • Compile code
go build
  • Compile for a specific file
go build -o <filename>
  • Run code
go run <file>.go
  • Install executable
go install

Tests

  • Run tests
go test
  • Run tests with details
go test -v
  • Run tests on all packages
go test ./...

Documentation

  • Show documentation for a package
go doc <package>
  • Show documentation and examples for a package
go doc -all <package>

Miscellaneous Tools

  • Format code
go fmt <file>.go
  • Format all project files
go fmt ./...
  • Check code style
go vet
  • Download dependencies
go mod download
  • Check dependency versions
go list -m -u all

Binary Generation

  • Compile for multiple platforms
GOOS=<operating-system> GOARCH=<architecture> go build -o <filename>

Example for compiling for 64-bit Linux:

GOOS=linux GOARCH=amd64 go build -o meu_programa_linux

Tool Specific Commands

  • Install a specific tool
go install <package>

Example for installing golint:

go install golang.org/x/lint/golint@latest

Package Management

  • Check for outdated packages
go list -u -m all

Debugging

  • Run the debugger

Note: dlv is part of the Delve package for debugging.

dlv debug

About

Repository to save my Go programming language studies notes and references.


Languages

Language:Go 92.5%Language:Shell 3.5%Language:HTML 2.1%Language:CSS 1.1%Language:Dockerfile 0.5%Language:Makefile 0.2%Language:templ 0.1%Language:JavaScript 0.0%