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
Babylon.js を使って試した色々な内容 / Various things I tried using Babylon.js / Babylon.js 勉強会 vol.5
you
PRO
0
250
ログ基盤・プラグイン・ダッシュボード、全部整えた。でも最後は人だった。
makikub
4
780
試されDATA SAPPORO [LT]Claude Codeで「ゆっくりデータ分析」
ishikawa_satoru
0
230
今年60歳のおっさんCBになる
kentapapa
1
240
スクラムを支える内部品質の話
iij_pr
0
300
解剖"React Native"
hacusk
0
110
Oracle AI Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
6
1.4k
GitHub Actions侵害 — 相次ぐ事例を振り返り、次なる脅威に備える
flatt_security
13
7.7k
ふりかえりを 「あそび」にしたら、 学習が勝手に進んだ / Playful Retros Drive Learning
katoaz
0
310
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
11k
Autonomous Database - Dedicated 技術詳細 / adb-d_technical_detail_jp
oracle4engineer
PRO
5
13k
組織的なAI活用を阻む 最大のハードルは コンテキストデザインだった
ixbox
1
910
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.7k
Test your architecture with Archunit
thirion
1
2.2k
Deep Space Network (abreviated)
tonyrice
0
110
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
170
Chasing Engaging Ingredients in Design
codingconduct
0
160
Become a Pro
speakerdeck
PRO
31
5.9k
Leo the Paperboy
mayatellez
6
1.6k
Odyssey Design
rkendrick25
PRO
2
560
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
160
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.7k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
160
Music & Morning Musume
bryan
47
7.1k
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/