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
270
Learning Unsung Gotchas of Go - Rashmi Nagpal
gopherconrussia
1
310
Прозрачный gRPC-proxy один-ко-многим - Андрей Смирнов
gopherconrussia
0
190
Из 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
170
Designing Pluggable Idiomatic Go Applications – Mark Bates
gopherconrussia
0
91
Other Decks in Programming
See All in Programming
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.6k
IBM Bob Dojo #1 仕様駆動開発入門
oniak3ibm
PRO
0
380
RAG の “R” を Swift で覗いてみる 〜「意味から探す」検索の仕組み〜
nao_randd
0
150
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.6k
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
970
半永久的に提供し続けられるプライベートクラウドを目指して ― 利用者の認知負荷を抑えるAPI抽象化とハードウェア世代交代の基盤設計
tomokon
0
480
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
34
16k
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.3k
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
8
5.7k
SREの越境 / SRE Collaboration
y0hgi
2
300
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
580
機械に任せるテスト、人が見るテスト ⽣成AIで引き直した、運⽤保守フェーズの線引き
dske104
0
180
Featured
See All Featured
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
The Curious Case for Waylosing
cassininazir
1
570
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Site-Speed That Sticks
csswizardry
13
1.6k
Designing Powerful Visuals for Engaging Learning
tmiket
1
600
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
320
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
750
Bash Introduction
62gerente
615
220k
Crafting Experiences
bethany
1
380
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
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