Add workaround for timezones on windows (#151)
Add workaround for timezones on windows Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/api/pulls/151
This commit is contained in:
19
vendor/4d63.com/embedfiles/LICENSE
generated
vendored
Normal file
19
vendor/4d63.com/embedfiles/LICENSE
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
Copyright (c) 2017, Leigh McCulloch
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
74
vendor/4d63.com/embedfiles/README.md
generated
vendored
Normal file
74
vendor/4d63.com/embedfiles/README.md
generated
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
# embedfiles
|
||||
[](https://goreportcard.com/report/github.com/leighmcculloch/embedfiles)
|
||||
|
||||
Embedfiles is a tool for embedding files into Go code.
|
||||
|
||||
Files are stored in a map of filenames to file data.
|
||||
|
||||
## Install
|
||||
|
||||
### Source
|
||||
|
||||
```
|
||||
go get 4d63.com/embedfiles
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
$ embedfiles
|
||||
Embedfiles embeds files into a map in a go file.
|
||||
|
||||
Usage:
|
||||
|
||||
embedfiles -out=files.go -pkg=main <paths>
|
||||
|
||||
Flags:
|
||||
|
||||
-file-names-var string
|
||||
name of the generated file names slice (default "fileNames")
|
||||
-files-var string
|
||||
name of the generated files slice (default "files")
|
||||
-out file
|
||||
output go file (default "files.go")
|
||||
-pkg package
|
||||
package name of the go file (default "main")
|
||||
-verbose
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
Given files:
|
||||
```
|
||||
$ echo "hello world" > file1
|
||||
$ mkdir morefiles
|
||||
$ echo "who are you?" > morefiles/file2
|
||||
```
|
||||
|
||||
Embed with `embedfiles`:
|
||||
```
|
||||
$ embedfiles file1 morefiles
|
||||
```
|
||||
|
||||
A new file `files.go` is created:
|
||||
```
|
||||
$ cat files.go
|
||||
// Generated by 4d63.com/embedfiles.
|
||||
|
||||
package main
|
||||
|
||||
var fileNames = []string{
|
||||
"file1", "morefiles/file2",
|
||||
}
|
||||
|
||||
var files = map[string][]byte{
|
||||
|
||||
"file1": []byte{
|
||||
31, 139, 8, 0, 0, 0, 0, 0, 2, 255, 202, 72, 205, 201, 201, 87, 40, 207, 47, 202, 73, 225, 2, 4, 0, 0, 255, 255, 45, 59, 8, 175, 12, 0, 0, 0,
|
||||
},
|
||||
|
||||
"morefiles/file2": []byte{
|
||||
31, 139, 8, 0, 0, 0, 0, 0, 2, 255, 42, 207, 200, 87, 72, 44, 74, 85, 168, 204, 47, 181, 231, 2, 4, 0, 0, 255, 255, 138, 46, 37, 108, 13, 0, 0, 0,
|
||||
},
|
||||
}
|
||||
```
|
3
vendor/4d63.com/embedfiles/go.mod
generated
vendored
Normal file
3
vendor/4d63.com/embedfiles/go.mod
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
module 4d63.com/embedfiles
|
||||
|
||||
go 1.13
|
125
vendor/4d63.com/embedfiles/main.go
generated
vendored
Normal file
125
vendor/4d63.com/embedfiles/main.go
generated
vendored
Normal file
@ -0,0 +1,125 @@
|
||||
package main // import "4d63.com/embedfiles"
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"flag"
|
||||
"fmt"
|
||||
"go/format"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
const tmpl = `
|
||||
// Generated by 4d63.com/embedfiles.
|
||||
|
||||
package {{.Package}}
|
||||
|
||||
var {{.FileNamesVar}} = []string{ {{range $name, $bytes := .Files}}"{{$name}}",{{end}} }
|
||||
|
||||
var {{.FilesVar}} = map[string][]byte{
|
||||
{{range $name, $bytes := .Files}}
|
||||
"{{$name}}": []byte{ {{range $bytes}}{{.}},{{end}} },
|
||||
{{end}}
|
||||
}
|
||||
`
|
||||
|
||||
type tmplData struct {
|
||||
Package string
|
||||
Files map[string][]byte
|
||||
FileNamesVar string
|
||||
FilesVar string
|
||||
}
|
||||
|
||||
func main() {
|
||||
out := flag.String("out", "files.go", "output go `file`")
|
||||
pkg := flag.String("pkg", "main", "`package` name of the go file")
|
||||
filesVar := flag.String("files-var", "files", "name of the generated files slice")
|
||||
fileNamesVar := flag.String("file-names-var", "fileNames", "name of the generated file names slice")
|
||||
verbose := flag.Bool("verbose", false, "")
|
||||
flag.Usage = func() {
|
||||
fmt.Fprintf(os.Stderr, "Embedfiles embeds files in the paths into a map in a go file.\n\n")
|
||||
fmt.Fprintf(os.Stderr, "Usage:\n\n")
|
||||
fmt.Fprintf(os.Stderr, " embedfiles -out=files.go -pkg=main <paths>\n\n")
|
||||
fmt.Fprintf(os.Stderr, "Flags:\n\n")
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
flag.Parse()
|
||||
|
||||
inputPaths := flag.Args()
|
||||
|
||||
if len(inputPaths) == 0 {
|
||||
flag.Usage()
|
||||
return
|
||||
}
|
||||
|
||||
f, err := os.Create(*out)
|
||||
if err != nil {
|
||||
printErr("creating file", err)
|
||||
return
|
||||
}
|
||||
|
||||
files := map[string][]byte{}
|
||||
for _, inputPath := range inputPaths {
|
||||
err = filepath.Walk(inputPath, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("walking: %s", err)
|
||||
}
|
||||
|
||||
if info.IsDir() {
|
||||
return nil
|
||||
}
|
||||
|
||||
if *verbose {
|
||||
fmt.Printf("%s ", path)
|
||||
}
|
||||
|
||||
contents, err := ioutil.ReadFile(path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("reading file: %s", err)
|
||||
}
|
||||
if *verbose {
|
||||
fmt.Printf("(%d bytes)\n", len(contents))
|
||||
}
|
||||
|
||||
path = filepath.ToSlash(path)
|
||||
files[path] = contents
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
printErr("walking", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
t, err := template.New("").Parse(tmpl)
|
||||
if err != nil {
|
||||
printErr("parsing template", err)
|
||||
return
|
||||
}
|
||||
|
||||
buf := bytes.Buffer{}
|
||||
err = t.Execute(&buf, &tmplData{Package: *pkg, Files: files, FilesVar: *filesVar, FileNamesVar: *fileNamesVar})
|
||||
if err != nil {
|
||||
printErr("generating code", err)
|
||||
return
|
||||
}
|
||||
|
||||
formatted, err := format.Source(buf.Bytes())
|
||||
if err != nil {
|
||||
printErr("formatting code", err)
|
||||
return
|
||||
}
|
||||
|
||||
f.Write(formatted)
|
||||
err = f.Close()
|
||||
if err != nil {
|
||||
printErr("finalizing file", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func printErr(doing string, err error) {
|
||||
fmt.Fprintf(os.Stderr, "Error %s: %s\n", doing, err)
|
||||
}
|
Reference in New Issue
Block a user