Learning Go by examples: part 3 - Create a CLI app in Go

This page summarizes the projects mentioned and recommended in the original post on dev.to

InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • We created our Git repository in the previous article, so now we just have to retrieve it locally:

  • cobra

    A Commander for modern Go CLI interactions

  • Cobra is both a library for creating powerful modern CLI applications and a program for generating applications and batch files.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • gophers

    Gopher artwork (Golang mascot) (by scraly)

  • var getCmd = &cobra.Command{ Use: "get", Short: "This command will get the desired Gopher", Long: `This get command will call GitHub respository in order to return the desired Gopher.`, Run: func(cmd *cobra.Command, args []string) { var gopherName = "dr-who.png" if len(args) >= 1 && args[0] != "" { gopherName = args[0] } URL := "https://github.com/scraly/gophers/raw/main/" + gopherName + ".png" fmt.Println("Try to get '" + gopherName + "' Gopher...") // Get the data response, err := http.Get(URL) if err != nil { fmt.Println(err) } defer response.Body.Close() if response.StatusCode == 200 { // Create the file out, err := os.Create(gopherName + ".png") if err != nil { fmt.Println(err) } defer out.Close() // Writer the body to file _, err = io.Copy(out, response.Body) if err != nil { fmt.Println(err) } fmt.Println("Perfect! Just saved in " + out.Name() + "!") } else { fmt.Println("Error: " + gopherName + " not exists! :-(") } }, }

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Build your own curl in Golang

    2 projects | dev.to | 27 Mar 2024
  • Scripts should be written using the project main language

    5 projects | news.ycombinator.com | 26 Mar 2024
  • How to read Cobra command line flag

    1 project | /r/golang | 29 Oct 2023
  • Dockerizing Golang CLI Tool - A Step-by-Step Guide

    3 projects | dev.to | 11 Oct 2023
  • Add License Headers to Your Code Files

    5 projects | dev.to | 28 Aug 2023