Skip to content

livebud/mod

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mod

Go Reference

A package for finding and manipulating go.mod files.

Features

  • Recursively traverses up the filesystem looking for go.mod
  • Supports binary builds with -trimpath
  • Extracted from Bud

Install

go get github.com/livebud/mod

Example

func main() {
  module, err := mod.Find(".")
  if err != nil {
    fmt.Fprintln(os.Stderr, err)
    os.Exit(1)
  }
  fmt.Println(module.Directory())
  fmt.Println(module.Import())
}
$ go run .
$GOPATH/src/github.com/livebud/mod
github.com/livebud/mod

Binary with -trimpath

$ go build -trimpath -ldflags " -X github.com/livebud/mod.path=$(go list -m) -X github.com/livebud/mod.dir=$(go list -m -f {{.Dir}})" .
$ ./main
$GOPATH/src/github.com/livebud/mod
github.com/livebud/mod

Contributors

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published