This repository has been archived by the owner on Aug 22, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/markbates/pkger
- Loading branch information
Showing
21 changed files
with
1,568 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM alpine | ||
|
||
EXPOSE 3000 | ||
COPY example /bin/ | ||
|
||
|
||
CMD /bin/example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module app | ||
|
||
go 1.13 | ||
|
||
require github.com/markbates/pkger v0.5.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package parser | ||
|
||
import ( | ||
"encoding/json" | ||
"go/token" | ||
"os" | ||
) | ||
|
||
var _ Decl = CreateDecl{} | ||
|
||
type CreateDecl struct { | ||
file *File | ||
pos token.Pos | ||
value string | ||
} | ||
|
||
func (d CreateDecl) String() string { | ||
b, _ := json.Marshal(d) | ||
return string(b) | ||
} | ||
|
||
func (d CreateDecl) MarshalJSON() ([]byte, error) { | ||
return json.Marshal(map[string]interface{}{ | ||
"type": "pkger.Create", | ||
"file": d.file, | ||
"pos": d.pos, | ||
"value": d.value, | ||
}) | ||
} | ||
|
||
func (d CreateDecl) File() (*File, error) { | ||
if d.file == nil { | ||
return nil, os.ErrNotExist | ||
} | ||
return d.file, nil | ||
} | ||
|
||
func (d CreateDecl) Pos() (token.Pos, error) { | ||
if d.pos <= 0 { | ||
return -1, os.ErrNotExist | ||
} | ||
return d.pos, nil | ||
} | ||
|
||
func (d CreateDecl) Value() (string, error) { | ||
if d.value == "" { | ||
return "", os.ErrNotExist | ||
} | ||
return d.value, nil | ||
} | ||
|
||
func (d CreateDecl) VirtualPaths() []string { | ||
return []string{d.value} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package parser | ||
|
||
import ( | ||
"encoding/json" | ||
"go/token" | ||
"os" | ||
) | ||
|
||
var _ Decl = MkdirAllDecl{} | ||
|
||
type MkdirAllDecl struct { | ||
file *File | ||
pos token.Pos | ||
value string | ||
} | ||
|
||
func (d MkdirAllDecl) String() string { | ||
b, _ := json.Marshal(d) | ||
return string(b) | ||
} | ||
|
||
func (d MkdirAllDecl) MarshalJSON() ([]byte, error) { | ||
return json.Marshal(map[string]interface{}{ | ||
"type": "pkger.MkdirAll", | ||
"file": d.file, | ||
"pos": d.pos, | ||
"value": d.value, | ||
}) | ||
} | ||
|
||
func (d MkdirAllDecl) File() (*File, error) { | ||
if d.file == nil { | ||
return nil, os.ErrNotExist | ||
} | ||
return d.file, nil | ||
} | ||
|
||
func (d MkdirAllDecl) Pos() (token.Pos, error) { | ||
if d.pos <= 0 { | ||
return -1, os.ErrNotExist | ||
} | ||
return d.pos, nil | ||
} | ||
|
||
func (d MkdirAllDecl) Value() (string, error) { | ||
if d.value == "" { | ||
return "", os.ErrNotExist | ||
} | ||
return d.value, nil | ||
} | ||
|
||
func (d MkdirAllDecl) VirtualPaths() []string { | ||
return []string{d.value} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.