Skip to content

Instantly share code, notes, and snippets.

@ma6174
Created July 29, 2015 15:17
Show Gist options
  • Save ma6174/9a966d4513c65c29a82c to your computer and use it in GitHub Desktop.
Save ma6174/9a966d4513c65c29a82c to your computer and use it in GitHub Desktop.
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