mirror of https://github.com/markbates/pkger.git
44 lines
642 B
Go
44 lines
642 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"log"
|
|
"net/http"
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/markbates/pkger"
|
|
)
|
|
|
|
func main() {
|
|
f, err := pkger.Open("github.com/gobuffalo/buffalo")
|
|
if err != nil {
|
|
log.Fatal("1", err)
|
|
}
|
|
defer f.Close()
|
|
|
|
fmt.Println(f.Path())
|
|
|
|
go func() {
|
|
time.Sleep(1 * time.Second)
|
|
res, err := http.Get("http://127.0.0.1:3000/app.go")
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
defer res.Body.Close()
|
|
|
|
_, err = io.Copy(os.Stdout, res.Body)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
if res.StatusCode >= 300 {
|
|
log.Fatal("code: ", res.StatusCode)
|
|
}
|
|
|
|
}()
|
|
|
|
log.Fatal(http.ListenAndServe(":3000", http.FileServer(f)))
|
|
}
|