加入收藏 | 设为首页 | 会员中心 | 我要投稿 北几岛 (https://www.beijidao.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

[Go] gocron源码阅读-go语言的结构体

发布时间:2021-05-21 06:46:09 所属栏目:大数据 来源: https://www.jb51.cc
导读:结构体类型 type 名字 struct{},下面这段是github.com/urfave/cli包里的代码,声明了一个App的结构体类型 type App struct { // The name of the program. Defaults to path.Base(os.Args[0]) Name string Full name of command for help,defaults to Name He

结构体类型 type 名字 struct{},下面这段是github.com/urfave/cli包里的代码,声明了一个App的结构体类型

type App struct {
    // The name of the program. Defaults to path.Base(os.Args[0])
    Name string
     Full name of command for help,defaults to Name
    HelpName  Description of the program.
    Usage  Text to override the USAGE section of help
    UsageText  Description of the program argument format.
    ArgsUsage  Version of the program
    Version  Description of the program
    Description  List of commands to execute
    Commands []*Command
     List of flags to parse
    Flags []Flag
}

?


点操作符也可以和指向结构体的指针一起工作,如果赋给的是个指针,那也可以直接用点来操作
type User struct{
Name string
}
user:=&User{Name:"taoshihan"}
fmt.Println(user.Name)

cliApp := cli.NewApp()
cliApp.Name = "gocron"
cliApp.Usage = "gocron service"
这个cli包下的NewApp方法返回的是*App类型,因此cliApp就是可以直接点操作里面的成员了

    return &App{
        Name:         filepath.Base(os.Args[0]),HelpName:     filepath.Base(os.Args["A new cli application",UsageText:    ""0.0.0(编辑:北几岛)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读