[Go] gocron源码阅读-go语言的结构体
2023-02-18 15:41:49 时间
结构体类型 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, }
相关文章
- git 命令别名配置
- C和C++安全编码复习
- git 无法提交空目录 ? (.gitkeep 文件的作用)
- PHP 字符串中 {} 的使用
- PowerShell 反弹渗透技巧
- Kali Linux安装AWVS漏扫工具
- brew 安装 nginx 配合PHP工作
- Linux 系统的安全加固
- C/C++ 编写并提取简易 ShellCode
- C/C++ 编写并提取通用 ShellCode
- Linux 系统下提取 ShellCode
- C/C++ 反调试与绕过手法
- C/C++ Inline Hook 钩子编写技巧
- C/C++ 将ShellCode注入进程内存
- Rsync+Inotify 实现数据同步
- NFS实现部署Linux文件共享
- Linux 应用Kickstart部署系统
- C/C++ 数据结构与算法笔记
- Django Web开发基础知识
- Django ORM 数据库常用操作