zoukankan      html  css  js  c++  java
  • [Go] gocron源码阅读-go语言的结构体

    结构体类型 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 string
        // Description of the program.
        Usage string
        // Text to override the USAGE section of help
        UsageText string
        // Description of the program argument format.
        ArgsUsage string
        // Version of the program
        Version string
        // Description of the program
        Description string
        // 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[0]),
            Usage:        "A new cli application",
            UsageText:    "",
            Version:      "0.0.0",
            BashComplete: DefaultAppComplete,
            Action:       helpCommand.Action,
            Compiled:     compileTime(),
            Writer:       os.Stdout,
        }
  • 相关阅读:
    webservice的简单介绍
    如何在page_load方法判断是服务器端控件引发的page_load方法
    android架构概述
    页面传递数组参数
    XML与DataTable/DataSet互转
    jquery调用asp.net 页面后台方法
    asp.net缓存机制
    jQuery操作radio,checkbox,select
    jquery选择器
    android开发环境的搭建过程
  • 原文地址:https://www.cnblogs.com/taoshihan/p/11860759.html
Copyright © 2011-2022 走看看