Skip to content

Instantly share code, notes, and snippets.

@alphazero
Created April 18, 2015 21:40
Show Gist options
  • Save alphazero/28d5b45c717eb06e6e81 to your computer and use it in GitHub Desktop.
Save alphazero/28d5b45c717eb06e6e81 to your computer and use it in GitHub Desktop.
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