fix: cwd
ci/woodpecker/push/goreleaser Pipeline was successful
Details
ci/woodpecker/push/goreleaser Pipeline was successful
Details
Signed-off-by: jolheiser <john.olheiser@gmail.com>main v0.0.7
parent
5c91d2e95a
commit
49a668d1a9
2
imp.go
2
imp.go
|
@ -16,7 +16,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func runImp(root, ignore string, write, gofumpt, gofumptExtra bool) error {
|
func runImp(root, ignore string, write, gofumpt, gofumptExtra bool) error {
|
||||||
mod, err := modInfo()
|
mod, err := modInfo(root)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
15
main.go
15
main.go
|
@ -29,11 +29,16 @@ func mainErr() error {
|
||||||
stdinFlag := fs.Bool("stdin", false, "Format stdin")
|
stdinFlag := fs.Bool("stdin", false, "Format stdin")
|
||||||
|
|
||||||
if err := fs.Parse(os.Args[1:]); err != nil {
|
if err := fs.Parse(os.Args[1:]); err != nil {
|
||||||
fmt.Println(err)
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
cwd, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if *stdinFlag {
|
if *stdinFlag {
|
||||||
mod, err := modInfo()
|
mod, err := modInfo(cwd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -46,9 +51,10 @@ func mainErr() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Print(string(formatted))
|
fmt.Print(string(formatted))
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
root := "."
|
root := cwd
|
||||||
if fs.NArg() > 0 {
|
if fs.NArg() > 0 {
|
||||||
root = fs.Arg(0)
|
root = fs.Arg(0)
|
||||||
}
|
}
|
||||||
|
@ -79,8 +85,9 @@ func (m *module) UnmarshalJSON(data []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func modInfo() (module, error) {
|
func modInfo(dir string) (module, error) {
|
||||||
cmd := exec.Command("go", "mod", "edit", "--json")
|
cmd := exec.Command("go", "mod", "edit", "--json")
|
||||||
|
cmd.Dir = dir
|
||||||
out, err := cmd.Output()
|
out, err := cmd.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return module{}, err
|
return module{}, err
|
||||||
|
|
Reference in New Issue