Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced go:generate with go:embed #738

Merged
merged 6 commits into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
24 changes: 21 additions & 3 deletions cmd/apps/skychat/chat.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//go:generate esc -o static.go -prefix static static

/*
skychat app for skywire visor
*/
package main

import (
"embed"
"encoding/json"
"flag"
"fmt"
"io/fs"
"net"
"net/http"
"os"
Expand Down Expand Up @@ -39,6 +39,9 @@ var (
connsMu sync.Mutex
)

//go:embed static
var embededFiles embed.FS

func main() {
appC = app.NewClient(nil)
defer appC.Close()
Expand All @@ -56,7 +59,7 @@ func main() {
conns = make(map[cipher.PubKey]net.Conn)
go listenLoop()

http.Handle("/", http.FileServer(FS(false)))
http.Handle("/", http.FileServer(getFileSystem(false)))
ersonp marked this conversation as resolved.
Show resolved Hide resolved
http.HandleFunc("/message", messageHandler)
http.HandleFunc("/sse", sseHandler)

Expand Down Expand Up @@ -200,3 +203,18 @@ func sseHandler(w http.ResponseWriter, req *http.Request) {
}
}
}

func getFileSystem(useOS bool) http.FileSystem {
if useOS {
fmt.Print("using live mode")
return http.FS(os.DirFS("static"))
}

fmt.Print("using embed mode")
fsys, err := fs.Sub(embededFiles, "static")
if err != nil {
panic(err)
}

return http.FS(fsys)
}
262 changes: 0 additions & 262 deletions cmd/apps/skychat/static.go

This file was deleted.

46 changes: 23 additions & 23 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,49 @@ module github.com/skycoin/skywire
go 1.16

require (
github.com/AudriusButkevicius/pfilter v0.0.0-20190627213056-c55ef6137fc6
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/VictoriaMetrics/metrics v1.12.3
github.com/AudriusButkevicius/pfilter v0.0.0-20210218141631-7468b85d810a
github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 // indirect
github.com/VictoriaMetrics/metrics v1.17.2
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
github.com/creack/pty v1.1.11 // indirect
github.com/go-chi/chi v4.1.2+incompatible
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/golang/protobuf v1.4.2 // indirect
github.com/go-ole/go-ole v1.2.5 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-github v17.0.0+incompatible
github.com/google/go-querystring v1.0.0 // indirect
github.com/google/uuid v1.1.1
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/uuid v1.2.0
github.com/gorilla/securecookie v1.1.1
github.com/klauspost/reedsolomon v1.9.9 // indirect
github.com/klauspost/reedsolomon v1.9.12 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/mholt/archiver/v3 v3.3.0
github.com/mmcloughlin/avo v0.0.0-20200523190732-4439b6b2c061 // indirect
github.com/pkg/errors v0.8.1 // indirect
github.com/mholt/archiver/v3 v3.5.0
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/profile v1.5.0
github.com/prometheus/client_golang v1.7.1 // indirect
github.com/schollz/progressbar/v2 v2.15.0
github.com/shirou/gopsutil v2.20.5+incompatible
github.com/sirupsen/logrus v1.7.0
github.com/skycoin/dmsg v0.0.0-20201216183836-dae8a7acfc14
github.com/shirou/gopsutil v3.21.3+incompatible
github.com/sirupsen/logrus v1.8.1
github.com/skycoin/dmsg v0.0.0-20210329160412-4e25fc9ad26c
github.com/skycoin/skycoin v0.27.1
github.com/skycoin/yamux v0.0.0-20200803175205-571ceb89da9f
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8
github.com/spf13/cobra v1.0.0
github.com/stretchr/testify v1.6.1
github.com/spf13/cobra v1.1.3
github.com/stretchr/testify v1.7.0
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161 // indirect
github.com/templexxx/xor v0.0.0-20191217153810-f85b25db303b // indirect
github.com/tjfoc/gmsm v1.3.2 // indirect
github.com/tjfoc/gmsm v1.4.0 // indirect
github.com/tklauser/go-sysconf v0.3.5 // indirect
github.com/toqueteos/webbrowser v1.2.0
github.com/xtaci/kcp-go v5.4.20+incompatible
github.com/xtaci/lossyconn v0.0.0-20200209145036-adba10fffc37 // indirect
go.etcd.io/bbolt v1.3.5
golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9 // indirect
golang.org/x/net v0.0.0-20200625001655-4c5254603344
golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf // indirect
golang.org/x/crypto v0.0.0-20210415154028-4f45737414dc // indirect
golang.org/x/net v0.0.0-20210420210106-798c2154c571
golang.org/x/sys v0.0.0-20210420205809-ac73e9fd8988
golang.org/x/term v0.0.0-20210406210042-72f3dc4e9b72 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
golang.zx2c4.com/wireguard v0.0.20200320
nhooyr.io/websocket v1.8.2
nhooyr.io/websocket v1.8.7
)

// Uncomment for tests with alternate branches of 'dmsg'
Expand Down
Loading