Installing COBRA Modern CLI - Backup Files Software From Scratch Written in Golang Tutorial #2

Опубликовано: 09 Октябрь 2024
на канале: Maharlikans Code
1,165
21

In this tutorial series #2, we are setting up the Cobra which is both a library for creating powerful modern CLI applications as well as a program to generate applications and command files that we can use for our "Gokopy" CLI application program to build the Gokopy Golang Project.

Install Cobra CLI: https://github.com/spf13/cobra

If you go with extra mile for buying me a cup of coffee, I appreciate it guys: https://ko-fi.com/maharlikanscode

#MaharlikansCode
#CobraCLI
#Golang
#LifeAsSoftwareDeveloper
#Maharlikans
#FilipinoSoftwareDeveloper
#GolangModernCLI

Source Codes:
*main.go file*
package main

import (
"gokopy/cmd"
)

func main() {
cmd.Execute()
}

*root.go*
package cmd

import (
"fmt"
"os"

"github.com/spf13/cobra"
)

var rootCmd = &cobra.Command{
Use: "gokopy",
Short: "A lightweight automated backup file software.",
Long: `A lightweight automated backup file software.`,
Version: "1.0.0",
// Run: func(cmd *cobra.Command, args []string) {
// // Do Stuff Here
// fmt.Println("Hello Cobra CLI application")
// },
}

func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}