diff --git a/examples/dynamic/pkger/Dockerfile b/examples/dynamic/pkger/Dockerfile new file mode 100644 index 0000000..4980ac8 --- /dev/null +++ b/examples/dynamic/pkger/Dockerfile @@ -0,0 +1,7 @@ +FROM alpine + +EXPOSE 3000 +COPY example /bin/ + + +CMD /bin/example diff --git a/examples/dynamic/pkger/Makefile b/examples/dynamic/pkger/Makefile new file mode 100644 index 0000000..dd14cf3 --- /dev/null +++ b/examples/dynamic/pkger/Makefile @@ -0,0 +1,5 @@ +default: + pkger + GOOS=linux go build -v -o example + docker build -t pkger:example . + docker run -p 3000:3000 pkger:example diff --git a/examples/dynamic/pkger/go.mod b/examples/dynamic/pkger/go.mod new file mode 100644 index 0000000..6d116ef --- /dev/null +++ b/examples/dynamic/pkger/go.mod @@ -0,0 +1,5 @@ +module app + +go 1.13 + +require github.com/markbates/pkger v0.5.1 diff --git a/examples/dynamic/pkger/go.sum b/examples/dynamic/pkger/go.sum new file mode 100644 index 0000000..8a207bc --- /dev/null +++ b/examples/dynamic/pkger/go.sum @@ -0,0 +1,22 @@ +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/markbates/pkger v0.5.1 h1:l0s55z4X5XbwIat2LyLe0HABMBswVK1GJbzLXQbuAXs= +github.com/markbates/pkger v0.5.1/go.mod h1:so/QD8FeTM0IilC3nRArkwOvUT+tsJsaXLFUAKmjzJk= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/examples/dynamic/pkger/main.go b/examples/dynamic/pkger/main.go new file mode 100644 index 0000000..114239f --- /dev/null +++ b/examples/dynamic/pkger/main.go @@ -0,0 +1,43 @@ +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) + 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!!")) + 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) + return f.Close() +} diff --git a/examples/dynamic/pkger/public/images/img1.png b/examples/dynamic/pkger/public/images/img1.png new file mode 100644 index 0000000..dfdb954 Binary files /dev/null and b/examples/dynamic/pkger/public/images/img1.png differ diff --git a/examples/dynamic/pkger/public/images/img2.png b/examples/dynamic/pkger/public/images/img2.png new file mode 100644 index 0000000..dfdb954 Binary files /dev/null and b/examples/dynamic/pkger/public/images/img2.png differ diff --git a/examples/dynamic/pkger/public/index.html b/examples/dynamic/pkger/public/index.html new file mode 100644 index 0000000..5a1d7ce --- /dev/null +++ b/examples/dynamic/pkger/public/index.html @@ -0,0 +1,12 @@ + + +
+ + +