John Siu Blog

Tech - Business Tool, Personal Toys

My Golang Project Update

☰ Table of Content

This is a recap of my new and updated golang projects

Go-MyGit

This is a replacement for my mygit, which I wanted to do it for a long time. Though bash is more than capable for the job, using golang made the process 10x more enjoyable. Using cobra and 2 of my own libraries allow a very structure code and command line layout.

Right now it support the following features:

  • Configuration File
    • remotes
    • groups
    • secrets
  • Selector for git servers
    • -g/–group
    • -r/–remote
  • Base(git) Commands
    • init
    • push
    • remote
      • add
      • list
      • remove
  • repository(api)
    • list all repo on server
    • create repo on server
    • get/set
      • description
      • private
      • public key(get only)
      • secret
      • topic
      • visibility
    • delete
      • repository
      • secret

All repo and base commands support processing multiple repos/dirs, with the exception of description and topic.

A minor drawback is the 11M binary size vs 15k for mygit. 🤦

Github: https://github.com/J-Siu/go-mygit

Releases: https://github.com/J-Siu/go-mygit/releases

Go-Crypto

This is a baby project to do NACL box seal anonymous from command line.

I created this for my final version of bash mygit to set github action secret.

Github: https://github.com/J-Siu/go-crypto

Releases: https://github.com/J-Siu/go-crypto/releases

Go-GitApi

This is the actual api library of go-mygit. It was a fun project to do and the final product support middleware behavior, which bring back memory from javascript.

Example:

1
2
3
4
5
6
7
8
9
apiP := gitapi.GitApiNew(... snip ...)
// Set Github header
apiP.HeaderGithub()
// Do POST
apiP.Post()
// Check status
var success bool = apiP.Res.Ok()

helper.ReportStatus(success, apiP.Repo + "(" + apiP.Name + ")", true)

Can be written as follow:

1
2
3
apiP := gitapi.GitApiNew(... snip ...).HeaderGithub().Post().Res.Ok()

helper.ReportStatus(success, apiP.Repo + "(" + apiP.Name + ")", true)

Of course this is not good coding style, especially golang doesn’t support the dot notation like javascript does. Following is how javascript format will look like:

1
2
3
4
5
6
7
var success = gitapi
  .GitApiNew(... snip ...)
  .HeaderGithub()
  .Post()
  .Res.Ok()

helper.ReportStatus(success, apiP.Repo + "(" + apiP.Name + ")", true)

Github: https://github.com/J-Siu/go-gitapi

Go-Helper

This package expand a lot due to go-gitapi and go-mygit. It grow from a single file for go-png2ico to 8 like following:

FileDescription
common.goDebug flag
crypto.goCrypto function
debug.goDebug functions
file.goFile/directory functions
gitCmd.goGit functions
myCmd.goexec.Command shell wrapper
report.goreport/log functions auto detect and apply json marshal indent
string.gostring/array functions

It really save me tones of time, especially report.go, when dealing with output in go-mygit.

Github: https://github.com/J-Siu/go-helper

John Siu

Update: 2022-05-12
Tag
comments powered by Disqus