Use go:embed instead of scripts/embedbinary.go

pull/110/head
lawl 3 years ago
parent 5a55f0538a
commit 3119fc5997

2
.gitignore vendored

@ -1,5 +1,3 @@
bin/
librnnoise.go
version.go
licenses.go
patreon.go

@ -1,6 +1,6 @@
module noisetorch
go 1.14
go 1.16
require (
gioui.org v0.0.0-20200630184602-223f8fd40ae4 // indirect

@ -19,15 +19,21 @@ import (
"github.com/lawl/pulseaudio"
_ "embed"
"github.com/aarzilli/nucular"
"github.com/aarzilli/nucular/style"
)
//go:generate go run scripts/embedbinary.go c/ladspa/rnnoise_ladspa.so librnnoise.go libRNNoise
//go:generate go run scripts/embedbinary.go assets/patreon.png patreon.go patreonPNG
//go:generate go run scripts/embedversion.go
//go:generate go run scripts/embedlicenses.go
//go:embed c/ladspa/rnnoise_ladspa.so
var libRNNoise []byte
//go:embed assets/patreon.png
var patreonPNG []byte
type device struct {
ID string
Name string

@ -1,31 +0,0 @@
package main
import (
"flag"
"fmt"
"io/ioutil"
"os"
"strconv"
)
func main() {
flag.Parse()
args := flag.Args()
b, err := ioutil.ReadFile(args[0])
if err != nil {
fmt.Printf("Couldn't read '%s': %v\n", args[0], err)
os.Exit(1)
}
out, _ := os.Create(args[1])
defer out.Close()
out.Write([]byte("package main \n\n//THIS FILE IS AUTOMATICALLY GENERATED BY `go generate` DO NOT EDIT!\n\nvar " + args[2] + " = []byte{\n"))
for i, c := range b {
out.Write([]byte(strconv.Itoa(int(c))))
out.Write([]byte(","))
if i%32 == 0 && i != 0 {
out.Write([]byte("\n"))
}
}
out.Write([]byte("}\n"))
}
Loading…
Cancel
Save