forked from mirror/pkger
the love cats
This commit is contained in:
parent
885aee89ac
commit
d9ff2b27b7
|
@ -0,0 +1,7 @@
|
|||
FROM alpine
|
||||
|
||||
EXPOSE 3000
|
||||
COPY example /bin/
|
||||
|
||||
|
||||
CMD /bin/example
|
|
@ -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
|
|
@ -0,0 +1,5 @@
|
|||
module app
|
||||
|
||||
go 1.13
|
||||
|
||||
require github.com/markbates/pkger v0.5.1
|
|
@ -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=
|
|
@ -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()
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title>HI</title>
|
||||
</head>
|
||||
<body>
|
||||
HELLO
|
||||
<img src="/images/img1.png" alt=""/>
|
||||
</body>
|
||||
</html>
|
|
@ -21,6 +21,7 @@ func run() error {
|
|||
return err
|
||||
}
|
||||
fmt.Println(info)
|
||||
|
||||
if err := pkger.MkdirAll("/foo/bar/baz", 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -30,6 +31,7 @@ func run() error {
|
|||
return err
|
||||
}
|
||||
f.Write([]byte("BIZ!!"))
|
||||
|
||||
if err := f.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -39,5 +41,6 @@ func run() error {
|
|||
return err
|
||||
}
|
||||
io.Copy(os.Stdout, f)
|
||||
|
||||
return f.Close()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue