Introduction
This challenge aims to test your understanding of the embed
package in Golang. The embed
package allows programs to include arbitrary files and folders in the Go binary at build time.
This challenge aims to test your understanding of the embed
package in Golang. The embed
package allows programs to include arbitrary files and folders in the Go binary at build time.
Your task is to modify the given code to embed files and folders into the Go binary and print their contents.
embed
package to embed files and folders.string
and []byte
types to store the contents of the embedded files.embed.FS
type to embed multiple files or folders with wildcards.## Use these commands to run the example.
## (Note: due to limitation on go playground,
## this example can only be run on your local machine.)
$ mkdir -p folder
$ echo "hello go" > folder/single_file.txt
$ echo "123" > folder/file1.hash
$ echo "456" > folder/file2.hash
$ go run embed-directive.go
hello go
hello go
123
456
In this challenge, you learned how to use the embed
package to embed files and folders into the Go binary at build time. You also learned how to use the string
and []byte
types to store the contents of the embedded files, and how to use the embed.FS
type to embed multiple files or folders with wildcards.