github.com/tilotech/tilores-cli@v0.28.0/internal/pkg/modulepath.go (about) 1 package pkg 2 3 import ( 4 "encoding/json" 5 "os/exec" 6 ) 7 8 // GetModulePath returns the current module path of the project. 9 func GetModulePath() (string, error) { 10 cmd := exec.Command("go", "mod", "edit", "-json") 11 out, err := cmd.CombinedOutput() 12 if err != nil { 13 return "", err 14 } 15 mp := struct { 16 Module struct { 17 Path string 18 } 19 }{} 20 err = json.Unmarshal(out, &mp) 21 if err != nil { 22 return "", err 23 } 24 return mp.Module.Path, nil 25 }