forked from babyname/fate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/godcong/fate
- Loading branch information
Showing
8 changed files
with
179 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"github.com/goextension/log" | ||
"github.com/spf13/cobra" | ||
"os" | ||
"path/filepath" | ||
"runtime" | ||
) | ||
|
||
func cmdCheck() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "check", | ||
Short: "check the env does correct", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
root := runtime.GOROOT() | ||
log.Infow("check", "GOROOT", runtime.GOROOT()) | ||
if e := zoneCheck(root); e != nil { | ||
log.Fatalw("zoneinfo check failed", "error", e) | ||
} | ||
fmt.Println("check all done!!!") | ||
}, | ||
} | ||
return cmd | ||
} | ||
func zoneCheck(root string) error { | ||
path := filepath.Join(root, "lib", "time") | ||
_, e := os.Stat(filepath.Join(path, "zoneinfo.zip")) | ||
if e != nil && os.IsNotExist(e) { | ||
_, e1 := os.Stat(filepath.Join(getCurrentPath(), "zoneinfo.zip")) | ||
if e1 != nil && os.IsNotExist(e) { | ||
return errors.New("zoneinfo file not found") | ||
} else if e1 != nil { | ||
return fmt.Errorf("found error in current path:%w", e1) | ||
} else { | ||
return nil | ||
} | ||
} else if e != nil { | ||
return fmt.Errorf("found error in go path:%w", e) | ||
} else { | ||
return nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/godcong/fate" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func versionCMD() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "version", | ||
Short: "print current version to screen", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
fmt.Println("version:", fate.Version) | ||
}, | ||
} | ||
return cmd | ||
} |
Oops, something went wrong.