Skip to content

Commit

Permalink
Use Go 1.16 embed (#140)
Browse files Browse the repository at this point in the history
* Use go 1.16 embed

* Upgrade go version to 1.16 in go.mod

* Fix index.html not showing on launch

* Update CI to use go 1.16
  • Loading branch information
Srinivasa314 authored Mar 22, 2021
1 parent 4d6397d commit 1006348
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 195 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
sudo apt-get update
sudo apt-get install -yqq google-chrome-stable
- name: Install Go
uses: actions/setup-go@v1
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
go-version: '1.16'
- name: Run tests
run: go test -v -race ./...
- name: Build examples
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* Call arbitrary JavaScript code from Go
* Asynchronous flow between UI and main app in both languages (async/await and Goroutines)
* Supports loading web UI from the local web server or via data URL
* Supports embedding all assets into a single binary
* Supports testing your app with the UI in the headless mode
* Supports multiple app windows
* Supports packaging and branding (e.g. custom app icons). Packaging for all
Expand Down Expand Up @@ -70,8 +69,7 @@ fmt.Println(m)

<p align="center"><img src="examples/counter/counter.gif" /></p>

Also, see [examples](examples) for more details about binding functions, embedding
assets and packaging binaries.
Also, see [examples](examples) for more details about binding functions and packaging binaries.

## Hello World

Expand Down
66 changes: 0 additions & 66 deletions examples/counter/assets.go

This file was deleted.

11 changes: 0 additions & 11 deletions examples/counter/gen.go

This file was deleted.

10 changes: 6 additions & 4 deletions examples/counter/main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//go:generate go run -tags generate gen.go

package main

import (
"embed"
"fmt"
"log"
"net"
Expand All @@ -15,6 +14,9 @@ import (
"github.com/zserge/lorca"
)

//go:embed www
var fs embed.FS

// Go types that are bound to the UI must be thread-safe, because each binding
// is executed in its own goroutine. In this simple case we may use atomic
// operations, but for more complex cases one should use proper synchronization.
Expand Down Expand Up @@ -65,8 +67,8 @@ func main() {
log.Fatal(err)
}
defer ln.Close()
go http.Serve(ln, http.FileServer(FS))
ui.Load(fmt.Sprintf("http://%s", ln.Addr()))
go http.Serve(ln, http.FileServer(http.FS(fs)))
ui.Load(fmt.Sprintf("http://%s/www", ln.Addr()))

// You may use console.log to debug your JS code, it will be printed via
// log.Println(). Also exceptions are printed in a similar manner.
Expand Down
108 changes: 0 additions & 108 deletions fs.go

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/zserge/lorca

go 1.13
go 1.16

require golang.org/x/net v0.0.0-20200222125558-5a598a2470a0

0 comments on commit 1006348

Please sign in to comment.