Skip to content

Commit

Permalink
Add version infomation and compile to mutil-platform
Browse files Browse the repository at this point in the history
  • Loading branch information
OhYee committed Sep 6, 2019
1 parent 5d42396 commit a89c212
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
Binary file modified bin/gcg
Binary file not shown.
Binary file added bin/gcg.exe
Binary file not shown.
Binary file added bin/gcg_x86.exe
Binary file not shown.
9 changes: 9 additions & 0 deletions compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
# CGO_ENABLED: 0
# GOOS: darwin、freebsd、linux、windows
# GOARCH: 386、amd64、arm

go build -o bin/gcg gcg.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o bin/gcg.exe gcg.go
CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -o bin/gcg_x86.exe gcg.go

12 changes: 11 additions & 1 deletion gcg.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import (
"text/template"
)

const (
version = "0.0.2"
helpText = "Using `gcg <json file> [<output file>]` to generate go file\nSuch as `gcg data.json` or `gcg data.json ../add.go`"
)

type arguments struct {
PackageName string `json:"package"`
ImportedPackage []interface{} `json:"import"`
Expand Down Expand Up @@ -79,8 +84,13 @@ func main() {
var outputFile *os.File
switch len(os.Args) {
case 1:
exitWhenFalse(false, "Using `gcg <json file> [<output file>]` to generate go file\nSuch as `gcg data.json` or `gcg data.json ../add.go`")
exitWhenFalse(false, helpText)
case 2:
if os.Args[1] == "-h" || os.Args[1] == "--help" {
exitWhenFalse(false, helpText)
} else if os.Args[1] == "-v" || os.Args[1] == "--version" {
exitWhenFalse(false, fmt.Sprintf("Go Code Generator version: %s\n", version))
}
inputFile = os.Args[1]
outputFile = os.Stdout
default:
Expand Down

0 comments on commit a89c212

Please sign in to comment.