Skip to content

axcdnt/go-mod-internals

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

This repo is merely a function, exported as it was a library. Its main purpose is to explore Go modules internals. Modules is the most recent way of managing dependencies in Go. From version 1.13+ modules became the default.

I first created it private and made it public so you may learn from it. I hope it works for your private repos too. I believe there are different ways to solve this problem. :)

Resolving private dependencies

Configurations

Environment variable

export GOPRIVATE="github.com/<username>,github.com/<username>,github.com/<username>"

Notice that it allows you to define multiple repos.

Enforcing SSH via Git

git config --global url."ssh://git@github.com/".insteadOf "https://github.com/"

Now, if you want to use it in another project, run the following:

go get -v github.com/axcdnt/go-mod-internals

The go.mod must be correctly updated with the code from this lib.

Dependencies resolved, it's now possible to import and use it:

package main

import "github.com/axcdnt/go-mod-internals/stringer"

func main() {
	stringer.Tokenize("what a cool string") // ["what", "a", "cool", "string"]
}

For more details, please check Go 1.13.

Docker

After a person asked on Gophers Slack how it works with Docker I decided to try. For the app using the lib, all you have to do is vendorize it:

go mod vendor