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
Goではじめるバックエンド開発
Search
ak2ie
June 17, 2023
Technology
0
48
Goではじめるバックエンド開発
2023/06/17「【Developers Guild】バックエンドエンジニア交流会」での発表資料です
ak2ie
June 17, 2023
Tweet
Share
More Decks by ak2ie
See All by ak2ie
Go言語CLIツールで生産効率UPした話
ak2ie
0
73
Notion APIと学ぶNext.js
ak2ie
0
370
NestJSのはじめ方
ak2ie
0
95
フロントエンドでDDDやってみた
ak2ie
0
63
初心者がシビックテックに参加してみた
ak2ie
0
87
Firebase についてとことん語りたい
ak2ie
0
100
D3.jsでグラフを描いてみた
ak2ie
0
97
Flutterはじめます
ak2ie
0
96
Other Decks in Technology
See All in Technology
本当のAWS基礎
toru_kubota
1
540
LayerXにおけるLLMプロダクト開発の今までとこれから
layerx
PRO
3
470
私が trocco を推す理由
__allllllllez__
1
270
一生覚えておきたい「システム開発=コミュニケーション」〜初めての実務案件振り返りLT〜
maimyyym
2
190
DMM.com アルファ室採用案内資料
hsugita
1
170
TechFeed Experts Night#27 〜 フロントエンドフレームワーク最前線 (Svelte)
baseballyama
1
550
Cypress or Playwright?
rainerhahnekamp
0
150
AOAI をきっかけに 社内の Azure 管理を見直した話
recruitengineers
PRO
1
390
Google Cloud Next '24 Recap(Cloud Run/k8s)
mokocm
0
260
MLOpsの「壁」を乗り越える、LINEヤフーの Data Quality as Code
lycorptech_jp
PRO
7
560
BPStudyの200回を中心にIT業界を振り返る。そしてこれから
haru860
3
310
チームでロジカルシンキングに改めて向き合っている話 〜学習環境と実践⽅法〜
sansantech
PRO
3
3k
Featured
See All Featured
Navigating Team Friction
lara
178
13k
From Idea to $5000 a Month in 5 Months
shpigford
377
45k
Making the Leap to Tech Lead
cromwellryan
124
8.5k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
21
1.6k
We Have a Design System, Now What?
morganepeng
43
6.8k
Bash Introduction
62gerente
604
210k
The Power of CSS Pseudo Elements
geoffreycrofte
60
5k
Six Lessons from altMBA
skipperchong
21
3k
A Tale of Four Properties
chriscoyier
151
22k
A designer walks into a library…
pauljervisheath
200
23k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
357
22k
No one is an island. Learnings from fostering a developers community.
thoeni
16
2.1k
Transcript
Goではじめる バックエンド開発 2023/06/17
自己紹介 • 名前:ak2ie • 職業:Webエンジニア • 好きなもの:コーヒー、YouTube
バックエンド どんな言語で開発してますか?
Ruby on Rails?
PHP?
TypeScript?
Go!
目次 • Goとは • Goを使っている企業 • Goの特徴 • HTTPサーバー •
テスト • DB操作
Goとは • Googleが2012年にリリースしたプログラミング言語 • マスコットキャラクターはGopher(ゴーファー) • 半年に1度バージョンアップし、最新バージョンは1.20 • ver.1系は後方互換性があるので、仕事でも安心して使える by
Renée French
Goを使っている企業 • メルカリ ◦ メルカリUSのバックエンドで採用 • ヤフー ◦ 分散オブジェクトストレージをGoで実装 https://findy-code.io/engineer-lab/go-findy-event-1
https://www.slideshare.net/techblogyahoo/go-go-conference-2017-spring
Goの特徴 • 静的型付き言語 • シンプルな構文(ループはfor文のみ) • 標準ライブラリが充実 ◦ HTTPリクエスト処理 ◦
DB操作 ◦ テスト • Goを初めて学ぶ方は「プログラミング言語 Go完全入門」がおすすめ http://tenn.in/go
HTTPサーバー • 標準ライブラリでHTTPリクエスト を処理できる • http://localhost:8080/hello で”hello world!”を返す package main
import ( "net/http" ) type Handler struct{} func Hello(w http.ResponseWriter, r *http.Request) { w.Write([]byte("hello world!")) } func main() { http.HandleFunc("/hello", Hello) http.ListenAndServe(":8080", nil) } 処理 ルーター
テスト • 標準ライブラリでテストを実 行できる • テスト関数 ◦ _test.goで終わる ◦ Testから始まる
◦ *testing.Tが引数 // main_test.go package main import ( "net/http" "net/http/httptest" "testing" ) func TestHello(t *testing.T) { r := httptest.NewRequest(http.MethodGet, "/hello", nil) w := httptest.NewRecorder() Hello(w, r) if w.Body.String() != "hello world!" { t.Errorf("result should be \"hello world!\", but %s", w.Body.String()) } } 検証 処理
DB操作 • 基本的操作は標準ライブラリで実装可能 • エンジンに応じてドライバーを使い分ける ◦ PostgreSQLなら”jackc/pgx”など • DB接続 ◦
db, err := sql.Open(“pgx”, “【接続情報】”) • クエリ実行 ◦ db.Query(“【クエリ】”)
まとめ • GoはGoogleがリリースしたプログラミング言語 • 現在ver.1.20が最新。ver.1系は後方互換性があるので仕事でも使える • 有名企業でも採用事例あり • 構文がシンプル •
標準ライブラリが充実 ◦ HTTPサーバー ◦ DB ◦ テスト