Created
October 15, 2018 23:39
-
-
Save j0shua/083706332fe25e4728d730b9c9e7a43f to your computer and use it in GitHub Desktop.
parse first 16 chars from hash (string) to int64
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 ( | |
"strconv" | |
"fmt" | |
"reflect" | |
) | |
func main() { | |
// Use the max value for signed 64 integer. http://golang.org/pkg/builtin/#int64 | |
var hash string = "0c821f675f132d790b3f25e79da739a7" | |
var short = hash[0:16] | |
fmt.Printf("short is %s\n", short) | |
i, err := strconv.ParseInt(short, 16, 64) | |
if err != nil { | |
panic(err) | |
} | |
fmt.Printf("%v with type %s!\n", i, reflect.TypeOf(i)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment