↓ Skip to main content
Go

Go Modules

·1 min

If you are like me and getting errors while trying to compile your go lang code without having a go.mod in v1.18

package src is not in GOROOT (/usr/local/Cellar/go/1.18.3/libexec/src/src)

Remember you have overlooked a basic change that happened post 1.16

Module Aware Mode

The go command now builds packages in module-aware mode by default, even when no go.mod is present.

> go env|grep GO111
GO111MODULE=""

Set it off

go env -w GO111MODULE=off

Try again

go test
PASS
ok      _/Users/samarthya/sourcebox/github.com/git.golang/project-one/src        0.099s

💬 You can also set GO111MODULE to auto to enable module-aware mode only when a go.mod file is present in the current directory or any parent directory.

go env -w GO111MODULE=auto

Author
Samarthya
Engineer, learner, tinkerer. This is my trophy shelf of everyday work and leisure.

Related

Kaniko: Jenkins Pipeline

So there are many things I have been simultaneously trying to learn & one of those is to learn how you can configure a pipeline Read more about Pipeline as Code (PaC) Objectives # Learn Jenkins deployment on Kubernetes Learn Jenkins Kubernetes Plugin Learn Jenkins Pipeline (Declarative) How to build and deploy images in Kubernetes cluster All right, with so many monkeys on my back I had to do things the way I know it works for me.

GoLang: Hash

·2 mins
Previously I talked about files, encoding in golang. In this LTD (learn to do) I will talk about hash package in general. https://blog.samarthya.me/wps/2021/01/30/golang-encoding/ Help # https://golang.org/pkg/hash/#Hash https://golang.org/pkg/crypto/#Hash.New https://golang.org/src/crypto/crypto.go?s=364:378#L6 https://golang.org/pkg/crypto/#pkg-subdirectories Package crypto collects common cryptographic constants. — Official golang documentation const ( MD4 Hash = 1 + iota // import golang.org/x/crypto/md4 MD5 // import crypto/md5 SHA1 // import crypto/sha1 SHA224 // import crypto/sha256 SHA256 // import crypto/sha256 SHA384 // import crypto/sha512 SHA512 // import crypto/sha512 MD5SHA1 // no implementation; MD5+SHA1 used for TLS RSA RIPEMD160 // import golang.org/x/crypto/ripemd160 SHA3_224 // import golang.org/x/crypto/sha3 SHA3_256 // import golang.org/x/crypto/sha3 SHA3_384 // import golang.org/x/crypto/sha3 SHA3_512 // import golang.org/x/crypto/sha3 SHA512_224 // import crypto/sha512 SHA512_256 // import crypto/sha512 BLAKE2s_256 // import golang.org/x/crypto/blake2s BLAKE2b_256 // import golang.org/x/crypto/blake2b BLAKE2b_384 // import golang.org/x/crypto/blake2b BLAKE2b_512 // import golang.org/x/crypto/blake2b ) Let’s try out a simple MD5 hasher.