Skip to content

Commit 01dd7a8

Browse files
committed
Add embed_bytes.go
1 parent 525efaa commit 01dd7a8

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package embeds
2+
3+
import (
4+
_ "embed"
5+
"encoding/hex"
6+
"os"
7+
)
8+
9+
//go:embed helloworld.txt
10+
var b []byte
11+
12+
// EmbedBytes は、embed パッケージの機能を確認するサンプルです (バイト列として値を取得)
13+
func EmbedBytes() error {
14+
dumper := hex.Dumper(os.Stdout)
15+
defer dumper.Close()
16+
17+
if _, err := dumper.Write(b); err != nil {
18+
return err
19+
}
20+
21+
return nil
22+
}

internal/examples/basic/embeds/examples.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ func NewRegister() mappings.Register {
1616
// Regist -- 登録します.
1717
func (r *register) Regist(m mappings.ExampleMapping) {
1818
m["embed_string"] = EmbedString
19+
m["embed_bytes"] = EmbedBytes
1920
}

0 commit comments

Comments
 (0)