Package to build MacOS and Web apps using Go, HTML and CSS.
Go Objective-C HTML JavaScript
Clone or download
Latest commit da99a08 Jul 14, 2018
Permalink
Failed to load latest commit information.
appjs Rename component to compo (#148) Jul 14, 2018
cmd/goapp Move packages to internal (#149) Jul 14, 2018
drivers Replace UUID by string (#152) Jul 14, 2018
examples Replace UUID by string (#152) Jul 14, 2018
html Replace UUID by string (#152) Jul 14, 2018
internal Replace UUID by string (#152) Jul 14, 2018
key key package Aug 20, 2017
.gitattributes Refactor window wip Feb 9, 2018
.gitignore Refactor elem (#147) Jul 13, 2018
.travis.yml Move packages to internal (#149) Jul 14, 2018
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md Feb 23, 2018
CONTRIBUTING.md update contribute.md Jul 13, 2018
History.md Release 2.6.3 Jul 14, 2018
LICENSE driver logic + context logic Oct 23, 2016
PULL_REQUEST_TEMPLATE.md Create PULL_REQUEST_TEMPLATE.md Feb 23, 2018
README.md Rename component to compo (#148) Jul 14, 2018
action.go Refactor logs decorators (#135) May 26, 2018
action_test.go Move packages to internal (#149) Jul 14, 2018
app.go Rename component to compo (#148) Jul 14, 2018
app_test.go Move packages to internal (#149) Jul 14, 2018
compo.go Rename component to compo (#148) Jul 14, 2018
compo_test.go Rename component to compo (#148) Jul 14, 2018
dock.go Rename component to compo (#148) Jul 14, 2018
driver.go Rename component to compo (#148) Jul 14, 2018
driver_test.go Move packages to internal (#149) Jul 14, 2018
elem.go Replace UUID by string (#152) Jul 14, 2018
error.go Refactor errors Feb 19, 2018
error_test.go Refactor errors Feb 19, 2018
event.go Replace UUID by string (#152) Jul 14, 2018
event_test.go Move packages to internal (#149) Jul 14, 2018
factory.go Rename component to compo (#148) Jul 14, 2018
factory_test.go Move packages to internal (#149) Jul 14, 2018
file.go notifications use mac rpc Mar 15, 2018
log.go Refactor logs decorators (#135) May 26, 2018
log_test.go Refactor logs decorators (#135) May 26, 2018
markup.go Replace UUID by string (#152) Jul 14, 2018
markup_test.go Move packages to internal (#149) Jul 14, 2018
menu.go Rename component to compo (#148) Jul 14, 2018
page.go Refactor logs decorators (#135) May 26, 2018
status.go Rename component to compo (#148) Jul 14, 2018
window.go Rename component to compo (#148) Jul 14, 2018

README.md

app

Build Status Go Report Card Coverage Status GoDoc Contribute Bitcoin Contribute Ethereum

Package to build MacOS and Web apps using Go, HTML and CSS.

hello

Table of Contents

Install

# Get package.
go get -u -v github.com/murlokswarm/app/...

Hello world

# Go to your go package.
cd $GOPATH/src/github.com/USERNAME/hello

# Install the required frameworks and generate the app structure.
goapp mac init
// main.go

func main() {
	app.Import(&Hello{})

	app.Run(&mac.Driver{
		OnRun: func() {
			newWindow()
		},

		OnReopen: func(hasVisibleWindow bool) {
			if !hasVisibleWindow {
				newWindow()
			}
		},
	})
}

func newWindow() {
	app.NewWindow(app.WindowConfig{
		Title:           "hello world",
		TitlebarHidden:  true,
		Width:           1280,
		Height:          768,
		BackgroundColor: "#21252b",
		DefaultURL:      "/Hello",
	})
}

type Hello struct {
	Name string
}

func (h *Hello) Render() string {
	return `
<div class="Hello">
	<h1>
		Hello
		{{if .Name}}
			{{.Name}}
		{{else}}
			world
		{{end}}!
	</h1>
	<input value="{{.Name}}" placeholder="Say something..." onchange="Name" autofocus>
</div>
	`
}
# Build the app.
goapp mac build

# Launch the app.
./hello

How it works?

app.Run starts the app. It takes an app.Driver as argument. Here we use the MacOS driver implementation. See other drivers.

When creating the window, we set the DefaultURL to our Hello component struct name: /Hello. It will load the Hello component when the window is displayed.

Components are structs that implement the app.Compo interface.

Render method returns a string that contains HTML5. It can be templated following Go standard template syntax:

HTML events like onchange are mapped to the targetted component field or method. Here, onchange is mapped to the field Name.

Additionally, CSS files can be dropped in PACKAGEPATH/resources/css/ directory. All .css files within that directory will be included.

See the full example.

Drivers

A driver contains specific code that allows the app package to work on multiple platforms.

Other drivers will come in the future.

Documentation

Examples

From package:

From community: