mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-07-15 12:28:55 +00:00
Update dependencies (#886)
This commit is contained in:
97
vendor/github.com/paulrosania/go-charset/data/generate.go
generated
vendored
97
vendor/github.com/paulrosania/go-charset/data/generate.go
generated
vendored
@ -1,97 +0,0 @@
|
||||
// +build ignore
|
||||
|
||||
// go run generate.go && go fmt
|
||||
|
||||
// The generate-charset-data command generates the Go source code
|
||||
// for github.com/paulrosania/go-charset/data from the data files
|
||||
// found in github.com/paulrosania/go-charset/datafiles.
|
||||
// It should be run in the go-charset root directory.
|
||||
// The resulting Go files will need gofmt'ing.
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
type info struct {
|
||||
Path string
|
||||
}
|
||||
|
||||
var tfuncs = template.FuncMap{
|
||||
"basename": func(s string) string {
|
||||
return filepath.Base(s)
|
||||
},
|
||||
"read": func(path string) ([]byte, error) {
|
||||
return ioutil.ReadFile(path)
|
||||
},
|
||||
}
|
||||
|
||||
var tmpl = template.Must(template.New("").Funcs(tfuncs).Parse(`
|
||||
// This file is automatically generated by generate-charset-data.
|
||||
// Do not hand-edit.
|
||||
|
||||
package data
|
||||
import (
|
||||
"github.com/paulrosania/go-charset/charset"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func init() {
|
||||
charset.RegisterDataFile({{basename .Path | printf "%q"}}, func() (io.ReadCloser, error) {
|
||||
r := strings.NewReader({{read .Path | printf "%q"}})
|
||||
return ioutil.NopCloser(r), nil
|
||||
})
|
||||
}
|
||||
`))
|
||||
|
||||
var docTmpl = template.Must(template.New("").Funcs(tfuncs).Parse(`
|
||||
// This file is automatically generated by generate-charset-data.
|
||||
// Do not hand-edit.
|
||||
|
||||
// The {{basename .Package}} package embeds all the charset
|
||||
// data files as Go data. It registers the data with the charset
|
||||
// package as a side effect of its import. To use:
|
||||
//
|
||||
// import _ "github.com/paulrosania/go-charset"
|
||||
package {{basename .Package}}
|
||||
`))
|
||||
|
||||
func main() {
|
||||
dataDir := filepath.Join("..", "datafiles")
|
||||
d, err := os.Open(dataDir)
|
||||
if err != nil {
|
||||
fatalf("%v", err)
|
||||
}
|
||||
names, err := d.Readdirnames(0)
|
||||
if err != nil {
|
||||
fatalf("cannot read datafiles dir: %v", err)
|
||||
}
|
||||
for _, name := range names {
|
||||
writeFile("data_"+name+".go", tmpl, info{
|
||||
Path: filepath.Join(dataDir, name),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func writeFile(name string, t *template.Template, data interface{}) {
|
||||
w, err := os.Create(name)
|
||||
if err != nil {
|
||||
fatalf("cannot create output file: %v", err)
|
||||
}
|
||||
defer w.Close()
|
||||
err = t.Execute(w, data)
|
||||
if err != nil {
|
||||
fatalf("template execute %q: %v", name, err)
|
||||
}
|
||||
}
|
||||
|
||||
func fatalf(f string, a ...interface{}) {
|
||||
fmt.Fprintf(os.Stderr, "%s\n", fmt.Sprintf(f, a...))
|
||||
os.Exit(2)
|
||||
}
|
Reference in New Issue
Block a user