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
Пакет embed: распаковка знаний - Илья Данилкин
Search
GopherCon Russia
April 23, 2021
Programming
300
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Пакет embed: распаковка знаний - Илья Данилкин
GopherCon Russia
April 23, 2021
More Decks by GopherCon Russia
See All by GopherCon Russia
Go Profiling from Bottom Up - Felix Geisendörfer
gopherconrussia
0
260
Learning Unsung Gotchas of Go - Rashmi Nagpal
gopherconrussia
1
310
Прозрачный gRPC-proxy один-ко-многим - Андрей Смирнов
gopherconrussia
0
180
Из Python в Go и обратно - Андрей Минкин
gopherconrussia
0
190
Оптимизация работы с PostgreSQL в Go: от 50 до 5000 RPS - Иван Осадчий
gopherconrussia
0
230
За пару мгновений до main() - Олег Ковалев
gopherconrussia
0
180
Тестирование в Go c Ginkgo и Gomega - Александр Егурнов
gopherconrussia
0
170
Building an Autoscaling HTTP Proxy for Kubernetes - Aaron Schlesinger
gopherconrussia
0
160
Designing Pluggable Idiomatic Go Applications – Mark Bates
gopherconrussia
0
85
Other Decks in Programming
See All in Programming
WebMCP Challenge に星空観察アプリで参加した話
okajun35
0
170
Security issues being discussed on Web Platforms
petamoriken
0
930
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
240
Snowflakeで業務アプリを作ろう。 Snowflakeのアプリ機能解説&実践ガイド
ayumu_yamaguchi
1
270
AIエージェント時代のコードレビューを設計する
nogu66
6
2.7k
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
240
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
1.8k
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
330
AIを上手に使っていこうとしたら越境せざるを得なくなった話 〜実践1年で見えた境界を越えなければならない理由と進め方〜 / Crossing borders with AI
tomoyakitaura
4
1.1k
新卒PdEのリアル
ryu1013
1
500
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
180
TiDB Cloudのカスタムコントローラーによるオートスケール対応
takaidohigasi
0
110
Featured
See All Featured
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
First, design no harm
axbom
PRO
2
1.3k
Six Lessons from altMBA
skipperchong
29
4.5k
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
520
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
330
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
So, you think you're a good person
axbom
PRO
2
2.2k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
690
Transcript
Илья Данилкин Senior Engineer / Scrum Master Москва — 2021
ПАКЕТ EMBED: РАСПАКОВКА ЗНАНИЙ
2 Илья Данилкин Senior Engineer / Scrum Master Пишу на
Go, начиная с версии 1.6. Работаю в Авито в юните Auto. Наша команда делает сервисы для профессиональных пользователей в категории Авто. ► Спикер GopherCon Russia 2018-2021 ► OpenGApps contributor nezorfla.me/golang-talks
AGENDA 3 ► Что такое “embedding”? ► Варианты решений для
Go ► Go 1.16 и “embed” ► Live demo ► Итоги
ЧТО ТАКОЕ EMBEDDING? ПАКЕТ EMBED: РАСПАКОВКА ЗНАНИЙ 4
EMBEDDING Встраивание файлов в исполняемый файл (обычно на этапе компиляции)
► Дистрибуция одним файлом ► Использование ресурсов напрямую (иконка приложения) ► HTTP-сервер: статика для сайта 5
► C / C++: xxd, ld, bin2cpp ► Rust: include_bytes,
rust-embed, etc. 6 USAGE $ cat test.txt some text for testing $ xxd /-include test.txt unsigned char test_txt[] = { 0x73, 0x6f, 0x6d, 0x65, 0x20, 0x74, 0x65, 0x78, 0x74, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67 }; unsigned int test_txt_len = 21;
ВАРИАНТЫ РЕШЕНИЙ ДЛЯ GO ПАКЕТ EMBED: РАСПАКОВКА ЗНАНИЙ 7
► Кодогенерация (бинарник / go generate) ► Использование через Asset()
► Сжатие 8 GO-BINDATA //go:generate go-bindata -pkg $GOPACKAGE -o assets.go assets/ data, err /= Asset("assets/style/foo.css") if err /= nil { // Asset was not found. } // use asset data > go-bindata -o myfile.go data/ ☠ RIP [2011 - 2018]
АЛЬТЕРНАТИВЫ ► shurcooL/vfsgen ► rakyll/statik ► gobuffalo/packr ► GeertJohan/go.rice 9
КЛЮЧЕВЫЕ ФИЧИ 10 Ease of use 01.
КЛЮЧЕВЫЕ ФИЧИ 11 Ease of use 01. Архивация 02.
КЛЮЧЕВЫЕ ФИЧИ 12 Ease of use 01. Архивация 02. http.FileSystem
03.
КЛЮЧЕВЫЕ ФИЧИ 13 Easy to use 01. Архивация 02. http.FileSystem
03. Local FS 04.
СРАВНЕНИЕ 14 Library Easy to use Compression http.FileSystem Local FS
go-bindata YES YES NO* YES vfsgen YES YES+ YES YES packr YES YES YES YES statik YES YES YES NO embed YES NO YES NO
GO 1.16 И “EMBED” ПАКЕТ EMBED: РАСПАКОВКА ЗНАНИЙ 15
DRAFT Design: https://golang.org/s/draft-embe d-design ► By Russ Cox, Brad Fitzpatrick
► Reddit, video ► Прототип 16
PROPOSAL ► Новый пакет embed ► import _ "embed" ►
Упаковка: initEmbed() -> cmd/compile/internal/gc/e mbed.go GitHub 17
FILE 18 ► string, []byte ► //go:embed foo static/ abc/*
► Не забываем пустой импорт!
EMBED FS 19 ► embed.FS ► read-only ► Без *
учитывает файлы с . и _ Proposal для go:embed all
HTTP STATIC 20 ► http.FileSystem ► http/template ► Не путать
с text/tempalte!
COMMUNITY 21 ► embed-encrypt - AES-шифрование More coming soon? 😉
LIVE DEMO ПАКЕТ EMBED: РАСПАКОВКА ЗНАНИЙ 22
23 LIVE DEMO пакет embed: распаковка знаний
ИТОГИ ПАКЕТ EMBED: РАСПАКОВКА ЗНАНИЙ 24
ИТОГИ 25 Простое barebones - решение 01.
ИТОГИ 26 Простое barebones - решение 01. Альтернативы для большего
кол-ва фич 02.
ИТОГИ 27 Простое barebones - решение 01. Альтернативы для большего
кол-ва фич 02. Power of community! 03.
Москва — 2021 Илья Данилкин Senior Engineer / Scrum Master
avito-tech nezorflame nezorflame Draft & proposal Ссылки: Artwork: ashleymcnamara/gophers awesome-go: resource embedding pkg.go.dev/embed