commit 09411f82886043420aaff2162e767cd00be3e765
parent 2adf9b55fbf9fe7710c66b586a93b30c1f9aefef
Author: francoispqt <francois@parquet.ninja>
Date: Sun, 24 Jun 2018 01:22:00 +0800
add handling of package path or path to a file
Diffstat:
1 file changed, 7 insertions(+), 0 deletions(-)
diff --git a/gojay/main.go b/gojay/main.go
@@ -32,6 +32,13 @@ func getPath() (string, error) {
if err != nil {
return "", err
}
+ if _, err := os.Stat(p); err != nil {
+ if os.IsNotExist(err) {
+ return filepath.Abs(os.Getenv("GOPATH") + "/src/" + *src)
+ } else {
+ return "", err
+ }
+ }
} else if len(os.Args) > 1 { // else if there is a command line arg, use it as path to a package $GOPATH/src/os.Args[1]
p, err = filepath.Abs(os.Getenv("GOPATH") + "/src/" + os.Args[1])
if err != nil {