Skip to content

amirhnajafiz/go-cobra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo

Go Cobra

Building a Dispatching Server using Golang programming language and Golang Cobra package with tls license and Sqlite database. The main idea of this project is to learn Cobra package and working with tls license.

In this application you can create a task then you can run it or change it or delete it. You can also see the list of the tasks and their status.

What do you learn from this project?

  • Golang Cobra
  • TLS certification
  • Sqlite

What is Cobra?

Cobra is a powerful library and tool in Golang that is used to create CLI (Command-Line Interface) applications. Cobra does this by providing tools that automate the process and provide key abstractions that increase developer productivity.

Read more about Cobra.

List of project commands:

  • serve: starting dispatching server
  • migrate: migrating database
  • crypto: generate certification files

TLS certification

Transport Layer Security (TLS) certificates—most commonly known as SSL, or digital certificates—are the foundation of a safe and secure internet.

TLS/SSL certificates secure internet connections by encrypting data sent between your browser, the website you’re visiting, and the website server. They ensure that data is transmitted privately and without modifications, loss or theft.

Read more about TLS.

How to use project?

Clone the repository and enter into main directory.

TLS files

You can create new TLS files:

go run main.go crypto

Database migration

To create a SQLite database:

go run main.go migrate

Dispatching server

Start server:

go run main.go serve
  • /tasks/{page?} GET
    • page argument is optional
    • returns a list of tasks
  • /run POST
    • run a task command
  • /tasks POST
    • creating a new task command
  • /task/{id} DELETE
    • remove an existing task
  • /task/{id} GET
    • returns a task status
  • /task/{id} PUT
    • updates an existing task