Created
July 29, 2015 15:17
-
-
Save ma6174/9a966d4513c65c29a82c to your computer and use it in GitHub Desktop.
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
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) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment