Created
August 5, 2015 21:34
-
-
Save andreis/5ef48eae4e5c9f2d9245 to your computer and use it in GitHub Desktop.
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 characters
| package main | |
| import "fmt" | |
| import "stablelib.com/v1/uniuri" | |
| // UUID is a random string of 32 characters. That's about 180 bits of entropy, so way over the | |
| // official UUIDv4 standard of 122 bits. | |
| type UUID string | |
| // New creates a new UUID | |
| func (u *UUID) New() UUID { | |
| return UUID(uniuri.NewLen(32)) | |
| } | |
| // Indexable is a bunch of informative fields put together | |
| type Indexable struct { | |
| ID UUID | |
| Tags map[string]struct{} | |
| Labels map[string]interface{} | |
| } | |
| func (i *Indexable) Tag(tag string) error { | |
| if i | |
| } | |
| // Node .. | |
| type Node struct { | |
| Indexable | |
| } | |
| // Edge .. | |
| type Edge struct { | |
| Indexable | |
| } | |
| // Graph .. | |
| type Graph struct { | |
| Nodes map[UUID]*Node | |
| Edges map[UUID]*Edge | |
| Tags map[string][]*Indexable | |
| } | |
| func main() { | |
| fmt.Println("YOLO") | |
| randStr := uniuri.New() | |
| fmt.Println(randStr, len(randStr)) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment