Learning Go Language with GitLab API

logo

Introduction

People often ask me how to learn Go language, and I usually suggest they start with a real project to quickly learn the language’s features. Personally, I started with small projects and gradually expanded their scope, from contributing to documentation to open-source projects, then learning how to modify the source code, and finally writing my own project. This learning method allows you to become familiar with the features of the Go language more quickly.

[Read More]

使用 GitLab API 學習 Go 語言

logo

前言

常有人問我如何學習 Go 語言,我通常建議他們從實際專案開始,這樣可以更快掌握語言特性。我個人也是先寫小專案,再逐步擴大範圍,從貢獻文件到開源專案,進而學習如何修改原始碼,最後再自己寫一個專案。這樣的學習方式能讓你更快熟悉 Go 語言的特性。

[Read More]

如何設計一套具備 Container 容器化技術的 CI/CD 平台 - Drone 開源專案

logo

今年一樣報名了 2024 年台北 Cloud Summit 活動,講的主題是『如何設計一套具備 Container 容器化技術的 CI/CD 平台?』,我相信大家在團隊內一定都有使用 CI/CD 工具,像是 Jenkins、GitLab CI、Travis CI、Circle CI 等等,這些工具都是非常好用的,但是想要在自己的環境中建置一套 CI/CD 平台,你會怎麼做呢?這次會帶您深入了解 Drone CI/CD 開源工具,並且透過實際的 Demo 來說明如何設計一套具備 Container 容器化技術的 CI/CD 平台。藉由 Drone 原始碼的解析,讓您了解 Drone 的運作原理,並且透過 Drone 的 Plugin 機制,讓您可以自行開發 Drone 的 Plugin,讓 Drone 可以更加符合您的需求。

[Read More]

Using singleflight in Go language to solve Cache Hotspot Invalid

photo

The diagram above illustrates a commonly used architecture in implementing web services, which involves adding a cache between the service and the database to reduce the load on the database. However, when implementing service integration, three major cache problems are often encountered: Cache Avalanche, Hotspot Invalid, Cache Penetration. Among them, Cache Hotspot Invalid is a very common issue. When the data in the cache expires or disappears, a large number of requests will simultaneously hit the backend database, causing an excessive load on the database and even leading to database crashes, as shown in the diagram where the cache key of a certain article expires. This article will introduce how to use the singleflight built into the Go language to solve the Cache Hotspot Invalid problem. This is a feature in the sync package that can prevent duplicate requests from hitting the backend database simultaneously.

photo

[Read More]

在 Go 語言用 singleflight 解決快取擊穿 (Cache Hotspot Invalid)

photo

上圖是在實作 Web 服務時常用的架構,會在服務跟資料庫之間加上快取,以減少資料庫的負載。然而在實作服務串接時,常常會遇到快取三大問題:雪崩、擊穿、穿透,其中 Cache Hotspot Invalid (快取擊穿) 是一個非常常見的問題,當快取中的資料過期或消失時,大量的請求會同時打到後端資料庫,這會導致資料庫的負載過大,甚至會導致資料庫掛掉,如下圖某篇文章的 cache key 過期。這篇文章將會介紹如何使用 Go 語言內建的 singleflight 來解決快取擊穿的問題,這是 sync 套件中的一個功能,可以避免重複的請求同時打到後端資料庫。

photo

[Read More]

生成式 AI CodeGPT 開發經驗談 - 台北 ModernWeb

photo

很高興可以到台北 ModerWeb 分享『生成式 AI CodeGPT 開發經驗談』,沒想到這主題這麼多人有興趣,第一次遇到滿場的現象。這場主要講授在今年 3 月由我自己開源的 CodeGPT 工具,身為軟體工程師,每天都一定會寫 Commit Message,而此工具會針對修改的 Code Diff 進行閱讀,並給出一次性的 Commit Message,讓軟體工程師不用再煩惱該如何寫 Commit Message。大家可以看看上面的封面圖,就可以知道我每天需要花多少時間在寫有用可閱讀的 Commit。

[Read More]

Go 語言專案開發 Hot Reload 工具 - air

go

大家都知道 Go 語言的開發環境是非常的快速,但是如果你想要在開發的時候,修改程式碼後,自動重新編譯並且執行,這時候就需要一個 Hot Reload 工具,這邊介紹一個 air,這個工具可以幫助你在開發的時候,自動重新編譯並且執行。安裝及設定方式非常簡單,不用 10 分鐘就可以打造自動編譯的開發環境。

[Read More]

用 ChatGPT 幫忙進行 Code Review 給建議

Cover

上一篇文章我們介紹了如何使用 ChatGPT 來自動生成 Commit Message,這篇文章來介紹如何使用 ChatGPT 來進行 Code Review。在月初開發的 CodeGPT 已經讓開發者可以使用 GPT-3.5-Turbo 來進行生成 Commit 總結,這個功能省下開發者不少整理開發內容時間,但是我覺得還是不夠,大家除了開發外,還花了很多時間在進行 Code Review,所以如果有工具,可以讓開發者可以提前知道優化的項目,這可以省下不少 Review 的時間。

[Read More]

用 ChatGPT 自動幫開發者產生 Commit Message

Cover

相信大家對 ChatGPT 不會很陌生,這是目前在生成式人工智慧 (AIGC: AI Generated Content) 內的當紅炸子雞,然而 ChatGPT 對於軟體工程師有什麼影響呢?能否透過 ChatGPT 改善團隊流程或協助開發?而我現在想到最直接的就是用 ChatGTP 幫忙寫 Git Commit Message,然而怎麼把 Commit Message 寫好可以參考這篇文章,為了能達成這目的,我用 Go 語言寫了一個 CLI 工具 CodeGPT (請大家幫忙分享),來協助軟體工程師整理開發內容。底下先看看使用 CodeGPT 來產生 Commit Message 的成果:

[Read More]

Automated solution for updating running Docker containers - watchtower

CI

Nowadays, most of us have containerized our services, and effectively managing and upgrading containers without affecting existing services is a critical issue. Two steps are required in the CI/CD process: first, packaging the environment as a Docker image and uploading it to the company’s private Docker registry; and second, after the upload is complete, possibly connecting to the machine via SSH, pulling the new image, and restarting the running service via the Graceful Shutdown mechanism. You can learn more about Graceful Shutdown in this article. I am going to introduces Watchtower, a brand new tool that automatically upgrades and updates running containers, allowing for further CD process streamlining. Developers only need to upload the Docker image, and the remote servers can update the running container automatically.

[Read More]