ebiten icon indicating copy to clipboard operation
ebiten copied to clipboard

use //go:embed to embed files

Open hajimehoshi opened this issue 3 years ago • 6 comments

https://go.googlesource.com/proposal/+/master/design/draft-embed.md

hajimehoshi avatar Jul 21 '20 15:07 hajimehoshi

TIL! Great!

gabstv avatar Jul 21 '20 16:07 gabstv

I'll use this when Go 1.17 is released (not Go 1.16). Then probably in August 2021.

hajimehoshi avatar Oct 22 '20 17:10 hajimehoshi

My two cents: works fine using the new embed feature in go v1.16, like this

import (
	"bytes"
	"embed"
	"image"
	"log"

	_ "image/png"

	"github.com/hajimehoshi/ebiten/v2"
)

//go:embed assets/*
var assetsFolder embed.FS

imgByte, err := assetsFolder.ReadFile("assets/main/idle.png")
if err != nil {
	log.Fatalln(err)
}
img, _, err := image.Decode(bytes.NewReader(imgByte))
if err != nil {
	log.Fatalln(err)
}
ebitenImg := ebiten.NewImageFromImage(img)

dnnnvx avatar Feb 18 '21 15:02 dnnnvx

Let's do this after Debian's default Go version is 1.16 or newer.

hajimehoshi avatar Aug 22 '21 09:08 hajimehoshi

Debian Bookworm (probably with Go 1.19) will be released in 2023-09, maybe.

hajimehoshi avatar Apr 10 '22 03:04 hajimehoshi

Note to myself:

We deterine the Go version by min(Debian's stable [1], Ubuntu's LTS [2])

[1] https://packages.debian.org/stable/golang [2] https://packages.ubuntu.com/jammy/golang (The URL indicates Ubuntu 22, rather than the LTS)

hajimehoshi avatar Jul 25 '22 07:07 hajimehoshi