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
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
Agent Harnessはどう作る?事例から学ぶAI Agentの設計思想
sergicalsix
0
230
AI時代の組織作り:チーム開発から「個人×AI」への移行と、持続可能な「開発資本」の築き方
ham0215
2
420
ゼロから作るWebアプリの新定番!?Amplify Gen 2 × AWS Blocksで実現する「開発速度とRDBの柔軟性のいいとこ取り」
amixedcolor
1
190
少ない人手 限られた予算 それでも守る 消せない・見つける・戻れる オールハザード型BCP on AWS / 20261107 Mitsutoshi Matsuo
shift_evolve
PRO
0
330
Claude Codeで作ったアプリを安全に公開する/Built with Claude Japan 2026
yoshidashingo
0
220
新米を「売り越さない」、Aurora DSQLで作る在庫ゼロ死守の限定ドロップEC
yama3133
0
200
AI時代に求められる優秀なTechLeadの振る舞い
pospome
11
16k
FinOpsを導入してマルチプロダクトのコスト最適化を実現する
kworkdev
PRO
0
140
「AIチャットからもできないの?」と言われたら ~業務アプリをMCP対応するときの認証・認可の勘所
oidfj
0
270
Gifu WordPress Meetup #200 に向けて、私たちには何ができるだろうか?/ 2026-11-07 Gifu WordPress Meetup
torounit
0
250
SSFの現在地 ― CAEP/RISCからAI Identityへ
oidfj
0
350
Content Mapper APIの応用例~CSS Modules、言語ファイル~
uhyo
2
630
Featured
See All Featured
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
We Have a Design System, Now What?
morganepeng
55
8.4k
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
BBQ
matthewcrist
90
10k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.3k
So, you think you're a good person
axbom
PRO
2
2.3k
Everyday Curiosity
cassininazir
0
400
ラッコキーワード サービス紹介資料
rakko
5
5.8M
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.8k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.6k
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/