Created
April 18, 2015 21:40
-
-
Save alphazero/28d5b45c717eb06e6e81 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" | |
) | |
var option = struct { | |
knob uint | |
}{ | |
knob: 4096, | |
} | |
func init() { | |
flag.UintVar(&option.knob, "k", option.knob, "somethin' to play with") | |
} | |
// fragment for server main | |
func main() { | |
flag.Parse() | |
// ... | |
} | |
// put in service path | |
func service() { | |
arr := alloc(option.knob) | |
lim := len(arr) - 1 | |
for i := 0; i < lim; i++ { | |
arr[i] = uint64(i) | |
} | |
copy(arr[1:], arr[:lim+1]) | |
} | |
func alloc(size uint) []uint64 { | |
return make([]uint64, size) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment