leoalves100 / golang-study

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

golang-study

Util

Executando

  1. Install asdf

  2. Adicionar plugin golang

asdf plugin-add golang https://github.com/kennyp/asdf-golang.git
  1. Instalar golang
asdf install

Commands

go mod

Inicializando modulo

go mod init <name-module>

 

go test

Executando test

# Entre na pasta contendo o teste

go test

# Executando de forma recursiva, é necessário ter modulo go
# Flags
# -v: verboso
# --cover: gera porcentagem de cobertura
# --coverprofile <nome-file>.txt: gera relatório de cobertura 
relatório de cobertura

go test ./...

Executando em paralelo

// Adicionar no início de cado função do teste

func TestParapelo(t *testing.T) {
    t.Parallel()

    return "true"
}

go tool

Obter informações gerado pelo --coverprofile

# Informações genéricas
go tool cover --func=<nome-file>.txt

# Gerando html
go tool cover --html=<nome-file>.txt

About


Languages

Language:Go 98.9%Language:HTML 1.1%