December 2021
Intermediate to advanced
510 pages
11h 20m
English
Cobra structures your application by creating a simple main.go file that only imports the package cmd and executes the application. The main.go file looks like this:
| | /* |
| | Copyright © 2020 The Pragmatic Programmers, LLC |
| | Copyrights apply to this source code. |
| | Check LICENSE for details. |
| | |
| | */ |
| | package main |
| | |
| | import "pragprog.com/rggo/cobra/pScan/cmd" |
| | |
| | func main() { |
| | cmd.Execute() |
| | } |
The core functionality of your application resides in the cmd package. When you run the command, the main function calls cmd.Execute to execute the root command of your application. You can find this function and the general structure of the program in the cmd/root.go file. The Execute ...
Read now
Unlock full access