pkger/pkging/pkgtest/internal/testdata/dynamic/main.go

47 lines
620 B
Go
Raw Normal View History

2019-10-23 20:19:39 +03:00
package main
import (
"fmt"
"io"
"log"
"os"
"github.com/markbates/pkger"
)
func main() {
if err := run(); err != nil {
log.Fatal(err)
}
}
func run() error {
info, err := pkger.Stat("/go.mod")
if err != nil {
return err
}
fmt.Println(info)
2019-10-23 20:23:02 +03:00
2019-10-23 20:19:39 +03:00
if err := pkger.MkdirAll("/foo/bar/baz", 0755); err != nil {
return err
}
f, err := pkger.Create("/foo/bar/baz/biz.txt")
if err != nil {
return err
}
f.Write([]byte("BIZ!!"))
2019-10-23 20:23:02 +03:00
2019-10-23 20:19:39 +03:00
if err := f.Close(); err != nil {
return err
}
f, err = pkger.Open("/foo/bar/baz/biz.txt")
if err != nil {
return err
}
io.Copy(os.Stdout, f)
2019-10-23 20:23:02 +03:00
2019-10-23 20:19:39 +03:00
return f.Close()
}