美文网首页
Parse command-line arguments

Parse command-line arguments

作者: hontu | 来源:发表于2017-10-08 19:00 被阅读0次
package main

import (
    "fmt"
    "flag"
    "math/rand"
)

func main() { 
    // Define flags 
    max := flag.Int("max", 6, "the max value") 
    // Parse 
    flag.Parse() 
    // Generate a number between 0 and max 
    fmt.Println(rand.Intn(*max)) 
}

相关文章

网友评论

      本文标题:Parse command-line arguments

      本文链接:https://www.haomeiwen.com/subject/golyyxtx.html