Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Let's build a URL shortener in Go
Search
Hanji Chung
December 18, 2023
Technology
280
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Let's build a URL shortener in Go
Hanji_DevFest2023
Hanji Chung
December 18, 2023
Transcript
36 slides
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/
More Decks by Hanji Chung
See All by Hanji Chung
PGO (Profile-Guided Optimization)_ The Secret Weapon for Accelerating Golang Programs
msc7wc91w
0
270
Other Decks in Technology
See All in Technology
OpenTelemetryで変わった 新時代のCloudWatchメトリクス監視
tsukuboshi
0
510
Is the Website Dying?
miriamschwab
0
200
現地速報! Microsoft Ignite アップデートレポート
kasada
1
460
認知の質も文化醸成も。数年取り組んで見えてきた技術広報のKPI設計 / Tech PR KPIs: Lessons on Awareness Quality and Culture After Several Years
bitkey
PRO
0
220
データから見る AI時代のエンジニア転職と採用
junya_okura
4
1.3k
Amazon EFS のマルウェアスキャンをClamAV で自前実装したら苦労した話
mtmtfactory01
0
120
さようならSSH鍵、こんにちはゼロトラスト ― AIフレンドリーで快適な自宅鯖SSH
atalie2m
14
7.6k
AWS Well-Arhitected Frameworkセキュリティの柱 について
miu_crescent
PRO
2
260
パスワードのない鍵で、 データを手元に置く
ginjihayashi
0
400
2026-11-16 JAWS-UG コンテナ支部 #31 ゆるLT大会 ECR のライフサイクルポリシーを いい感じに設定したい / ECR Lifecycle policy
masasuzu
3
630
技術書典で本を売る流れ
yoshimura_datam
0
160
こんなに変わった! AWSネットワークの常識
shotashiratori
16
12k
Featured
See All Featured
Technical Leadership for Architectural Decision Making
baasie
4
660
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
390
Color Theory Basics | Prateek | Gurzu
gurzu
1
530
Typedesign – Prime Four
hannesfritz
42
3.2k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
1.1k
BBQ
matthewcrist
90
10k
The Cost Of JavaScript in 2023
addyosmani
56
10k
Producing Creativity
orderedlist
PRO
348
41k
The untapped power of vector embeddings
frankvandijk
2
2k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
410
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.7k
Agile that works and the tools we love
rasmusluckow
331
22k