goapp

module
v9.0.0-...-93bb0e4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2023 License: MIT

README

<h1 align="center">
    <a href="https://go-app.dev">
        <img alt="go-app"  width="150" height="150" src="https://storage.googleapis.com/murlok-github/icon-192.png">
    </a>
</h1>

<p align="center">
	<a href="https://github.com/surdeus/goapp/actions"><img src="https://github.com/surdeus/goapp/actions/workflows/build.yml/badge.svg?branch=master" alt="GitHub actions"></a>
    <a href="https://goreportcard.com/report/github.com/surdeus/goapp"><img src="https://goreportcard.com/badge/github.com/surdeus/goapp" alt="Go Report Card"></a>
	<a href="https://GitHub.com/surdeus/goapp/releases/"><img src="https://img.shields.io/github/release/surdeus/goapp.svg" alt="GitHub release"></a>
	<a href="https://pkg.go.dev/github.com/surdeus/goapp/v9/pkg/app"><img src="https://img.shields.io/badge/dev-reference-007d9c?logo=go&logoColor=white&style=flat" alt="pkg.go.dev docs"></a>
    <a href="https://twitter.com/jonhymaxoo"><img alt="Twitter URL" src="https://img.shields.io/badge/twitter-@jonhymaxoo-35A9F8?logo=twitter&style=flat"></a>
    <a href="https://opencollective.com/go-app" alt="Financial Contributors on Open Collective"><img src="https://opencollective.com/go-app/all/badge.svg?label=open+collective&color=4FB9F6" /></a>
</p>

Go-app is a package for **building progressive web apps (PWA)** with the [Go programming language (Golang)](https://golang.org) and [WebAssembly (Wasm)](https://webassembly.org).

Shaping a UI is done by using a **[declarative syntax](https://go-app.dev/declarative-syntax) that creates and compose HTML elements only by using the Go programing language**.

It **uses [Go HTTP standard](https://golang.org/pkg/net/http) model**.

An app created with go-app can out of the box **runs in its own window**, **supports offline mode**, and is **SEO friendly**.

## Documentation (built with go-app)

[![go-app documentation](docs/web/images/go-app.png)](https://go-app.dev)

## Install

**go-app** requirements:

- [Go 1.18](https://golang.org/doc/go1.17) or newer
- [Go module](https://github.com/golang/go/wiki/Modules)

```sh
go mod init
go get -u github.com/surdeus/goapp/v9/pkg/app
```

## Declarative syntax

Go-app uses a [declarative syntax](https://go-app.dev/declarative-syntax) so you can **write reusable component-based UI elements** just by using the Go programming language.

Here is a Hello World component that takes an input and displays its value in its title:

```go
type hello struct {
	app.Compo

	name string
}

func (h *hello) Render() app.UI {
	return app.Div().Body(
		app.H1().Body(
			app.Text("Hello, "),
			app.If(h.name != "",
				app.Text(h.name),
			).Else(
				app.Text("World!"),
			),
		),
		app.P().Body(
			app.Input().
				Type("text").
				Value(h.name).
				Placeholder("What is your name?").
				AutoFocus(true).
				OnChange(h.ValueTo(&h.name)),
		),
	)
}
```

## Standard HTTP

Apps created with go-app complies with [Go standard HTTP](https://golang.org/pkg/net/http) package interfaces.

```go
func main() {
	// Components routing:
	app.Route("/", &hello{})
	app.Route("/hello", &hello{})
	app.RunWhenOnBrowser()

	// HTTP routing:
	http.Handle("/", &app.Handler{
		Name:        "Hello",
		Description: "An Hello World! example",
	})

	if err := http.ListenAndServe(":8000", nil); err != nil {
		log.Fatal(err)
	}
}
```

## Getting started

**Read the [Getting Started](https://go-app.dev/getting-started) document**.

## Built with go-app

- [Lofimusic.app](https://lofimusic.app/collegemusic-lonely)
- [Murlok.io](https://murlok.io/)
- [liwasc](https://pojntfx.github.io/liwasc/)
- [go-app Docs](https://go-app.dev/)

## Contributors

### Code Contributors

This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].

<a href="https://github.com/surdeus/goapp/graphs/contributors"><img src="https://opencollective.com/go-app/contributors.svg?width=890&button=false" /></a>

### Financial Contributors

Become a financial contributor and help us sustain [go-app](https://github.com/surdeus/goapp) development. [[Contribute](https://opencollective.com/go-app/contribute)]

#### Individuals

<a href="https://opencollective.com/go-app"><img src="https://opencollective.com/go-app/individuals.svg?width=890"></a>

#### Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/go-app/contribute)]

<a href="https://opencollective.com/go-app/organization/0/website"><img src="https://opencollective.com/go-app/organization/0/avatar.svg"></a>
<a href="https://opencollective.com/go-app/organization/1/website"><img src="https://opencollective.com/go-app/organization/1/avatar.svg"></a>
<a href="https://opencollective.com/go-app/organization/2/website"><img src="https://opencollective.com/go-app/organization/2/avatar.svg"></a>
<a href="https://opencollective.com/go-app/organization/3/website"><img src="https://opencollective.com/go-app/organization/3/avatar.svg"></a>
<a href="https://opencollective.com/go-app/organization/4/website"><img src="https://opencollective.com/go-app/organization/4/avatar.svg"></a>
<a href="https://opencollective.com/go-app/organization/5/website"><img src="https://opencollective.com/go-app/organization/5/avatar.svg"></a>
<a href="https://opencollective.com/go-app/organization/6/website"><img src="https://opencollective.com/go-app/organization/6/avatar.svg"></a>
<a href="https://opencollective.com/go-app/organization/7/website"><img src="https://opencollective.com/go-app/organization/7/avatar.svg"></a>
<a href="https://opencollective.com/go-app/organization/8/website"><img src="https://opencollective.com/go-app/organization/8/avatar.svg"></a>
<a href="https://opencollective.com/go-app/organization/9/website"><img src="https://opencollective.com/go-app/organization/9/avatar.svg"></a>

Directories

Path Synopsis
docs
src
pkg
analytics
Package analytics provides functions to send analytics to analytics stores such as Google Analytics.
Package analytics provides functions to send analytics to analytics stores such as Google Analytics.
app
Package app is a package to build progressive web apps (PWA) with Go programming language and WebAssembly.
Package app is a package to build progressive web apps (PWA) with Go programming language and WebAssembly.
cli
Package cli is a package to build CLI programs.
Package cli is a package to build CLI programs.
logs
Package logs implements functions to manipulate logs.
Package logs implements functions to manipulate logs.
ui
Package ui provides a set of components to organize an application layout.
Package ui provides a set of components to organize an application layout.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL