Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Let's build a URL shortener in Go
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Hanji Chung
December 18, 2023
Technology
0
270
Let's build a URL shortener in Go
Hanji_DevFest2023
Hanji Chung
December 18, 2023
Tweet
Share
More Decks by Hanji Chung
See All by Hanji Chung
PGO (Profile-Guided Optimization)_ The Secret Weapon for Accelerating Golang Programs
msc7wc91w
0
230
Other Decks in Technology
See All in Technology
テストプロセスにおけるAI活用 :人間とAIの共存
hacomono
PRO
0
110
20年以上続く PHP 大規模プロダクトを Kubernetes へ ── クラウド基盤刷新プロジェクトの4年間
oogfranz
PRO
0
140
形式手法特論:SMT ソルバで解く認可ポリシの静的解析 #kernelvm / Kernel VM Study Tsukuba No3
ytaka23
1
700
スケールアップ企業でQA組織が機能し続けるための組織設計と仕組み〜ボトムアップとトップダウンを両輪としたアプローチ〜
tarappo
3
290
Kiroで見直す開発プロセスとAI-DLC
k_adachi_01
0
110
AgentCoreとLINEを使った飲食店おすすめアプリを作ってみた
yakumo
2
110
Cortex Code CLI と一緒に進めるAgentic Data Engineering
__allllllllez__
0
550
SLI/SLO 導入で 避けるべきこと3選
yagikota
0
140
プラットフォームエンジニアリングはAI時代の開発者をどう救うのか
jacopen
8
4.1k
事例から紐解くSHIFT流QA支援 ~大規模プロジェクトの品質管理支援、QA組織立ち上げ~ / 20260320 Nozomu Koketsu
shift_evolve
PRO
0
100
エンジニアリングマネージャーの仕事
yuheinakasaka
0
120
頼れる Agentic AI を支える Datadog のオブザーバビリティ / Powering Reliable Agentic AI with Datadog Observability
aoto
PRO
0
240
Featured
See All Featured
KATA
mclloyd
PRO
35
15k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.2k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.7k
My Coaching Mixtape
mlcsv
0
82
Designing for Performance
lara
611
70k
Paper Plane
katiecoart
PRO
0
48k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.2k
GraphQLとの向き合い方2022年版
quramy
50
14k
How to Talk to Developers About Accessibility
jct
2
160
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
0
460
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
180
Transcript
Let's build a URL shortener in Go 韓吉 (Hanji)
About me • Freelancer, but open to work • 3+
backend work experience • Only using Golang in toy projects My LinkedIn
Slides
Github repo
Summary • Project Setup 🛠 • Igniting The Web Server
☄ • Store Service Setup 🛠 • Storage API Design • Shortener Generator Algorithm • Handlers & Endpoints
Project Setup 🛠 • Initialize the go project, using go
mod $ go mod init your-projectname • Create main.go file and add the code • Installing project dependencies $ go get github.com/go-redis/redis/v8 $ go get -u github.com/gin-gonic/gin
Download Redis • https://redis.io/docs/install/install-redis/
Igniting The Web Server ☄
Igniting The Web Server ☄ • Launching the web server
for first time • Run again the main.go file and go to http://localhost:9808/ in the browser or any rest client tool
Store Service Setup 🛠
Create a sub-directory
Setting up our wrappers around Redis
Storage API design and Implementation
func SaveUrlMapping
func RetrieveInitialUrl
Testing 🧪
Install the testing tools $ go get github.com/stretchr/testify
Setting up the the tests shell
Test the store service initialization
Test the storage APIs
Shortener Generator Algorithm
Create a sub-directory
SHA256
Base58 Encoded
Generate algorithm
Testing
Handlers & Endpoints
Create a sub-directory
Define handlers stubs
Setting endpoints
Request model definition
func CreateShortUrl
func HandleShortUrlRedirect
Demo time!!!
Demo curl --request POST --data '{ "long_url": "https://www.google.com/", "user_id" :
"123456789" }' http://localhost:9808/create-short-url
Reference • https://www.eddywm.com/lets-build-a-url-shortener-in-go/