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
Hanji Chung
December 18, 2023
Technology
270
0
Share
Let's build a URL shortener in Go
Hanji_DevFest2023
Hanji Chung
December 18, 2023
More Decks by Hanji Chung
See All by Hanji Chung
PGO (Profile-Guided Optimization)_ The Secret Weapon for Accelerating Golang Programs
msc7wc91w
0
240
Other Decks in Technology
See All in Technology
推し活エージェント
yuntan_t
1
860
ブラックボックス化したMLシステムのVertex AI移行 / mlops_community_62
visional_engineering_and_design
1
290
ふりかえりを 「あそび」にしたら、 学習が勝手に進んだ / Playful Retros Drive Learning
katoaz
0
300
Databricks Appsで実現する社内向けAIアプリ開発の効率化
r_miura
0
330
Oracle AI Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
6
1.4k
仕様通り動くの先へ。Claude Codeで「使える」を検証する
gotalab555
8
2.8k
AgentCore RuntimeからS3 Filesをマウントしてみる
har1101
2
340
TanStack Start エコシステムの現在地 / TanStack Start Ecosystem 2026
iktakahiro
1
330
「できない」のアウトプット 同人誌『精神を壊してからの』シリーズ出版を 通して得られたこと
comi190327
3
590
パワポ作るマンをMCP Apps化してみた
iwamot
PRO
0
310
Data Enabling Team立ち上げました
sansantech
PRO
0
280
あるアーキテクチャ決定と その結果/architecture-decision-and-its-result
hanhan1978
2
510
Featured
See All Featured
How to Ace a Technical Interview
jacobian
281
24k
Are puppies a ranking factor?
jonoalderson
1
3.2k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.2k
Evolving SEO for Evolving Search Engines
ryanjones
0
170
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
170
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
220
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
150
Testing 201, or: Great Expectations
jmmastey
46
8.1k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
470
How STYLIGHT went responsive
nonsquared
100
6k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
480
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/