⛔ [DEPRECATED] This project is no longer maintained. Use official
module golang.org/x/mod
, link https://pkg.go.dev/golang.org/x/mod
This are project for fun. Parse and read go module. Read go module
Install go get -u github.com/uudashr/go-module
Given go.mod
file
module my/thing
require other/thing v1.0.2
require new/thing v2.3.4
exclude old/thing v1.2.3
replace bad/thing v1.4.5 => good/thing v1.4.5
package main
import module "github.com/uudashr/go-module"
func main() {
b, err := ioutil.ReadFile("go.mod")
if err != nil {
panic(err)
}
mod, err := module.Parse(string(b))
if err != nil {
panic(err)
}
_ = mod // now we have mod file
// mod.Requires
// mod.Excludes
// mod.Repalces
}