Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Let's build a URL shortener in Go
Search
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
220
Other Decks in Technology
See All in Technology
意外とあった SQL Server 関連アップデート + Database Savings Plans
stknohg
PRO
0
190
小さな判断で育つ、大きな意思決定力 / 20251204 Takahiro Kinjo
shift_evolve
PRO
1
460
eBPFとwaruiBPF
sat
PRO
4
2.3k
Playwright x GitHub Actionsで実現する「レビューしやすい」E2Eテストレポート
kinosuke01
0
100
エンジニアリングマネージャー はじめての目標設定と評価
halkt
0
190
HIG学習用スライド
yuukiw00w
0
110
こがヘンだよ!Snowflake?サービス名称へのこだわり
tarotaro0129
0
110
【CEDEC+KYUSHU2025】学生・若手必見!テクニカルアーティスト 大全 ~仕事・スキル・キャリアパス、TAの「わからない」を徹底解剖~
cygames
PRO
0
100
Microsoft Agent 365 を 30 分でなんとなく理解する
skmkzyk
1
460
あなたの知らないDateのひみつ / The Secret of "Date" You Haven't known #tqrk16
expajp
0
120
ブロックテーマとこれからの WordPress サイト制作 / Toyama WordPress Meetup Vol.81
torounit
0
370
Playwrightのソースコードに見る、自動テストを自動で書く技術
yusukeiwaki
12
4.2k
Featured
See All Featured
Balancing Empowerment & Direction
lara
5
790
Understanding Cognitive Biases in Performance Measurement
bluesmoon
31
2.7k
Optimizing for Happiness
mojombo
379
70k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.5k
BBQ
matthewcrist
89
9.9k
Typedesign – Prime Four
hannesfritz
42
2.9k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
700
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.7k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Java REST API Framework Comparison - PWX 2021
mraible
34
9k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
380
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/