Skip to content

Latest commit

 

History

History
220 lines (171 loc) · 3.85 KB

README.md

File metadata and controls

220 lines (171 loc) · 3.85 KB

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