Advertisement
Guest User

Untitled

a guest
May 28th, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "flag"
  5. )
  6.  
  7. var option = struct {
  8. knob uint
  9. }{
  10. knob: 4096,
  11. }
  12.  
  13. func init() {
  14. flag.UintVar(&option.knob, "k", option.knob, "somethin' to play with")
  15. }
  16.  
  17. // fragment for server main
  18. func main() {
  19. flag.Parse()
  20. // ...
  21. }
  22.  
  23. // put in service path
  24. func service() {
  25. arr := alloc(option.knob)
  26. lim := len(arr) - 1
  27. for i := 0; i < lim; i++ {
  28. arr[i] = uint64(i)
  29. }
  30. copy(arr[1:], arr[:lim+1])
  31. }
  32. func alloc(size uint) []uint64 {
  33. return make([]uint64, size)
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement