Contents

Writing a github extension in go

I hadn’t put any thought into using the github or gitlab CLI for a long time, but both are pretty useful. We are using standard github for projects and also a self installed gitlab. Both CLIs are golang programs.

First we need to authenticate.

⋊> ◦ gh auth login                                                         
? What account do you want to log into? GitHub.com
? You're already logged into github.com. Do you want to re-authenticate? Yes
? What is your preferred protocol for Git operations? SSH
? Upload your SSH public key to your GitHub account? /Users/niko/.ssh/id_rsa_m1.pub
? Title for your SSH key: GitHub CLI
? How would you like to authenticate GitHub CLI? Login with a web browser

! First copy your one-time code: 4024-84CC
Press Enter to open github.com in your browser... 
✓ Authentication complete.
- gh config set -h github.com git_protocol ssh
✓ Configured git protocol

✓ Uploaded the SSH key to your GitHub account: 
✓ Logged in as hellonico
gh extension install redraw/gh-install  

https://pkg.go.dev/github.com/cli/go-gh#section-readme

Using the Gitlab CLI

Find the certificate for OTC: https://stackoverflow.com/questions/40051213/where-is-golang-picking-up-root-cas-from/67622500#67622500

brew install glab

Use a proxy: https://tkzo.jp/blog/golang-http-client-use-proxy/

export HTTPS_PROXY="socks5://localhost:10090"

https://docs.gitlab.com/ee/integration/glab/ https://tkzo.jp/blog/golang-http-client-use-proxy/

https://www.infoq.com/news/2023/01/GitHub-simplifies-cli-extension/ https://oxylabs.io/blog/curl-with-proxy https://support.apple.com/guide/keychain-access/change-the-trust-settings-of-a-certificate-kyca11871/mac https://gitlab.otc/-/profile/personal_access_tokens https://gitlab.com/gitlab-org/cli