Upgrade to Pro — share decks privately, control downloads, hide ads and more …

golang tokyo go tools

mom0tomo
April 19, 2019

golang tokyo go tools

mom0tomo

April 19, 2019
Tweet

More Decks by mom0tomo

Other Decks in Technology

Transcript

  1. Go ͸ίϚϯυ/πʔϧ͕ॆ࣮ͯ͠ ͍Δ • go ίϚϯυ • go tool •

    ඪ४ɾ४ඪ४ύοέʔδͰఏڙ͞Ε͍ͯΔ • IDEʹཔΒͳͯ͘΋շదʹ։ൃͰ͖Δ
  2. $ go env GOARCH="amd64" GOBIN="" GOCACHE="/home/alex/.cache/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux"

    GOOS="linux" GOPATH="/home/alex/go" GOPROXY="" GORACE="" GOROOT="/usr/local/go" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GCCGO="gccgo" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go- build245740092=/tmp/go-build -gno-record-gcc-switches" 14
  3. $ gofmt . $ gofmt foo.go // Options // -d

    : diffΛඪ४ग़ྗ͢Δ // -l : ϑΝΠϧ໊Λඪ४ग़ྗ͢Δ // -w : ্ॻ͖อଘ͢Δ // -s : ه๏Λγϯϓϧʹ͢Δ // Ұཡ͸ https://godoc.org/github.com/gophersjp/go/src/cmd/gofmt 17
  4. $ go fmt . $ go fmt foo.go // $

    gofmt -l -w ͱಉ͡͸ͨΒ͖ // formatͨ͠಺༰Ͱ্ॻ͖ͯ͠ϑΝΠϧ໊Λඪ४ग़ྗ͢Δ 18
  5. $ go vet . $ go vet foo.go // ίʔυΛ੩తղੳͯ͠ه๏ΛνΣοΫ͢Δ

    // ίϯύΠϥʹ͸ݕ஌Ͱ͖ͳ͍΋ͷΛݟ͚ͭͯ͘ΕΔ 20