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
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
ファシリテーション勉強中 その場に何が求められるかを考えるようになるまで / 20260123 Naoki Takahashi
shift_evolve
PRO
3
370
持続可能な開発のためのミニマリズム
sansantech
PRO
4
560
新規事業 toitta におけるAI 機能評価の話 / AI Feature Evaluation in toitta
pokutuna
0
260
Databricks Free Edition講座 データエンジニアリング編
taka_aki
0
2.8k
さくらのクラウドでのシークレット管理を考える/tamachi.sre#2
fujiwara3
1
220
20260120 Amazon VPC のパブリックサブネットを無くしたい!
masaruogura
2
160
いよいよ仕事を奪われそうな波が来たぜ
kazzpapa3
2
220
クラウドセキュリティの進化 — AWSの20年を振り返る
kei4eva4
0
160
困ったCSVファイルの話
mottyzzz
2
360
BiDiってなんだ?
tomorrowkey
2
480
Claude Codeベストプラクティスまとめ
minorun365
42
24k
SREの仕事を自動化する際にやっておきたい5つのポイント
jacopen
6
980
Featured
See All Featured
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
110
Rebuilding a faster, lazier Slack
samanthasiow
85
9.4k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
42
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.8k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
260
Designing for Timeless Needs
cassininazir
0
120
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
370
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
110
Believing is Seeing
oripsolob
1
38
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
400
How GitHub (no longer) Works
holman
316
140k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
0
1.8k
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/