dfang
(fang duan)
October 19, 2020, 3:30am
1
package main
import (
"github.com/qor/admin"
)
func main() {
}
I use go module for this, the package github.com/qor/admin
is downloaded to ~/go/pkg/mod/github.com/qor/admin@v0.0.0-20201015070726-29e78837de93/
how can i get this path programmatically ?
NobbZ
(Norbert Melzer)
October 19, 2020, 7:20am
2
You shouldn’t need to and I’m not aware of a way to get that information. Especially as the location might not be available anymore at runtime.
dfang
(fang duan)
October 19, 2020, 9:36am
3
i can get it with
go list -f '{{.Dir}}' "github.com/qor/admin"
but i want to get it with go code (except os.Exec way)
NobbZ
(Norbert Melzer)
October 19, 2020, 5:14pm
4
Why exactly do you need it? It’s not guaranteed to be available at runtime!
The packages code will be statically linked into your application and then you can move the program to other hosts which do not even need to have go installed.
system
(system)
Closed
January 17, 2021, 5:14pm
5
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.