Created
July 29, 2015 15:17
-
-
Save ma6174/9a966d4513c65c29a82c to your computer and use it in GitHub Desktop.
Revisions
-
Ma Weiwei created this gist
Jul 29, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ package main import ( "flag" "fmt" "log" "strconv" ) func main() { isDecode := flag.Bool("d", false, "decode") flag.Parse() str := flag.Arg(0) if *isDecode { n, err := strconv.ParseUint(str, 36, 64) if err != nil { log.Fatal(err) } fmt.Println(str, n) } else { n, err := strconv.ParseUint(str, 10, 64) if err != nil { log.Fatal(err) } out := strconv.FormatUint(n, 36) fmt.Println(str, out) } }