This is an example of the cobra project

Related tags

Miscellaneous Devops
Overview

Devops

cmd and mian.go

This is an example of the cobra project

Execute the following command in the current path to compile the project,you will appear a ly executable file.

compile install
go build -o ly  main.go
use

Use ly --help, you will be prompted how to use the ly command

Show Current Time. For example:
With this command, you can view current time or customize the time format.
Usage:
  ly [command]
Available Commands:
  completion  generate the autocompletion script for the specified shell
  help        Help about any command
  show        Display the current time
  version     A brief description of your command
Flags:
  -h, --help   help for ly
example

How to use ly

ly version    #显示当前ly版本
ly show       #展示当前时间  2021-08-26 13:24:25
ly show parse -f  "2006/01/02 15:04:05"  #将把当前时间格式化成"2006/01/02 15:04:05" 2021/08/26 13:26:55

Example

Algorithm algorithm example

coroutine example

Algorithm algorithm example

NetPing

project instruction ping written in go

Ping once per minute (ping 10 packets, interval 0.5, recording delay and packet loss)

txt

Save the data in a txt file

main.go

Defines a map of type interface{}

var ipInfo = make(map[string]interface{})

ipInfo["Addr"] = pinger.Addr()
ipInfo["Ip"] = pinger.IPAddr()
ipInfo["Sent"] = pinger.PacketsSent
ipInfo["Received"] = pinger.PacketsRecv
ipInfo["Loss"] = stats.PacketLoss
ipInfo["Avg"] = stats.AvgRtt
ipInfo["Time"] = time.Now().Format("2006/01/02 15:04:05")
txt_v2

Defines a structure

type Packets struct {
Time     string        `json:"time"`
Addr     string        `json:"addr"`
Ip       *net.IPAddr   `json:"ip""`
Sent     int           `json:"sent"`
Received int           `json:"received"`
Loss     float64       `json:"loss"`
Avg      time.Duration `json:"avg""`
}


ipInfo = Packets{
Time:     time.Now().Format("2006/01/02 15:04:05"),
Addr:     pinger.Addr(),
Ip:       pinger.IPAddr(),
Sent:     pinger.PacketsSent,
Received: pinger.PacketsRecv,
Loss:     stats.PacketLoss,
Avg:      stats.AvgRtt,
}
You might also like...
An example event-driven application using Atmo and NATS

Atmo + NATS Example Project This repo is an example of using Atmo with NATS as a streaming messaging layer. In this example, Atmo connects to NATS and

Minimal example app of hexagonal architecture in go

Hexagonal Architecture Minimal example of hexagonal architecture (ports & adapters) in go. Resources T

Example app using labstack/echo and ozzo-validator.

Example app using labstack/echo and ozzo-validator.

Example hello-world service uses go-fx-grpc-starter boilerplate code

About Example hello-world service uses https://github.com/srlk/go-fx-grpc-starter boilerplate code. Implementation A hello world grpc service is creat

Go clean architecture fully working example

Burp - clean architecture app Burp is a CRUD app managing beers. Front-end is written in Angular 12. Database in this example is mongodb. Root project

Simple example program using CRUD operations to interface with azcosmos

Simple example program using CRUD operations to interface with azcosmos

A reproducible example for an issue I'm encoutering when deploying my gunicorn app to nginx

Ngnix Issue This is a minimum, reproducible example for an issue I'm encoutering when deploying my gunicorn app to nginx. Installation (Linux) Webserv

Example of using advanced gRPC error model

grpcerrors Example of using advanced gRPC error model

Example showing how to implement a basic mutating webhook

Kubernetes Mutating Webhook example This shows a basic implementation of a mutating webhook. Setup Note: This relies on TLS certificates to function c

Owner
flyone
flyone
This example implements a basic example of how to create your own modules, and how to call them from other modules

This example implements a basic example of how to create your own modules, and how to call them from other modules. In addition, an example of how to do unit tests is developed.

null 1 Feb 1, 2022
Example programs for the Gio project.

Gio Examples Example programs for the Gio project. Issues File bugs and TODOs through the issue tracker or send an email to ~eliasnaur/[email protected].

Gio 82 Dec 20, 2022
Example project for Temporal microservice orchestarion.

Temporal Microservice Introduction This project is created to understand Temporal's Microservice approachment. The repo contains: Example Temporal Mic

Engin Sefa Güngör 1 Oct 4, 2022
Moby Project - a collaborative project for the container ecosystem to assemble container-based systems

The Moby Project Moby is an open-source project created by Docker to enable and accelerate software containerization. It provides a "Lego set" of tool

Moby 64.8k Jan 2, 2023
Placeholder for the future project (lets-go-chat)Placeholder for the future project (lets-go-chat)

Placeholder for the future project (lets-go-chat)Placeholder for the future project (lets-go-chat)

null 0 Jan 10, 2022
An example client implementation written in GO to access the CyberVox platform API

About This is an example client implementation written in GO to access the CyberVox platform API.

Cyberlabs AI 15 Nov 7, 2022
Example blog built with Go and the Cosmic Headless CMS 🔥

Go + Cosmic This repo contains an example blog starter that is built with Go, and Cosmic. See live demo hosted on Heroku Prerequisites Go (I recommend

Cosmic 7 May 8, 2022
this is an example of hystrix-go usage in web dev

hystrix-go-example this is an example of hystrix-go usage in web dev Explanation this example contains 2 service: alpha as our main service, circuit b

Vembry 2 Apr 22, 2022
Concurrency Lab 1 Go Example

Concurrency Lab 1 If you're stuck look at examples on Go by Example Using the lab sheet There are two ways to use the lab sheet, you can either: creat

null 0 Oct 11, 2021
Concurrency Lab 2 Go Example

Concurrency Lab 2 If you're stuck look at examples on Go by Example Using the lab sheet There are two ways to use the lab sheet, you can either: creat

null 0 Oct 12, 2021