Member-only story

Golang SlackBot Tutorial

Manage Static Assets in Golang

New ways to do it with Golang 1.16 new package “embed” — Ideal for SlackBots

Alexandre Couëdelo

Microsoft Oss Conference/database

Golang 1.16 new embed package helps you manage static assets, embedding them in the application binary and making them easy to use. I can see several applications of this new package, including managing JSON payload for my Slack Bot messages.

Overview of the new package embed

Any files from a package or package subdirectory can be embedded and retrieved as a variable of type string or bytes[].

You can also retrieve your embedded files with a variable of type FS and, you can even define which file needs to be embedded in your application using a glob pathname.

No responses yet

Write a response