1. 转发朋友圈送书活动中奖名单:
[1] 格日德吉
[2] 舜安-我有一头小毛驴
恭喜这两位朋友,稍后我们会在后台私信中奖的朋友,请及时回复邮寄地址
2. 提建议活动暂未收到有效建议,该活动改为长期。
附抽奖程序:
`package main`` ``import (` `"bytes"` `"crypto/rand"` `"flag"` `"fmt"` `"io/ioutil"` `"log"` `"math/big"``)`` ``func main() {` `var userfile string` `var max int64` `flag.StringVar(&userfile, "input", "", "set input user file")` `flag.Int64Var(&max, "max", 1, "set max user")` `flag.Parse()`` ` `txt, err := ioutil.ReadFile(userfile)` `if err != nil {` `log.Println("read file", err)` `return` `}` `lines := bytes.Split(txt, []byte("\n"))` `if max >= int64(len(lines)) {` `log.Println("max should little than users")` `return` `}` `count := len(lines)` `var flags = make([]bool, count)` `var counter int64` `for counter < max {` `n, err := rand.Int(rand.Reader, big.NewInt(int64(count)-counter))` `if err != nil {` `log.Panic(err)` `}` `idx := n.Int64()` `if flags[idx] {` `continue` `} else {` `fmt.Printf("[%d] %v\n", counter+1, string(lines[idx]))` `flags[idx] = true` `counter++` `}` `}``}`` `