gogui

package module
v0.0.0-...-b740842 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2021 License: MIT Imports: 13 Imported by: 0

README

Golangci lint Tests GoDoc GitHub license Go Report Card

gogui

This library is a GUI alternative for Go which uses the Chrome browser (or a default browser). The application communicates with the browser via WebSocket message using simple JSON.

You can write server-side code in Go and client-side code in Javascript.

Requirements

This requires

  • git
  • go 1.10+
  • web browser
    • Newest Chrome browser is recommended.
    • firefox
    • Microsoft Edge

Platforms

  • Linux
  • OSX
  • Windows

Installation

$ go get -u github.com/AidosKuneen/gogui

Example

See example directory

Contribution

Improvements to the codebase and pull requests are encouraged.

Dependencies and Licenses

github.com/AidosKuneen/gogui  MIT License
github.com/gorilla/websocket  BSD 2-clause "Simplified" License 
Golang Standard Library       BSD 3-clause License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Client is a middleman between the websocket connection and the hub.

func (*Client) Close

func (c *Client) Close()

Close close connection.

func (*Client) Emit

func (c *Client) Emit(name string, dat interface{}, f interface{}) error

Emit emits "name" event with dat.

func (*Client) Error

func (c *Client) Error(err error)

Error emits an error message.

func (*Client) On

func (c *Client) On(name string, f interface{}) error

On register a func which for event "name".

func (*Client) OnConnect

func (c *Client) OnConnect(f func())

OnConnect register a func which is called when connected..

func (*Client) OnDisconnect

func (c *Client) OnDisconnect(f func())

OnDisconnect register a func which is called when disconnected.

func (*Client) OnError

func (c *Client) OnError(f func(error))

OnError register a func when error

type GUI

type GUI struct {
	Finished  chan error
	Connected chan struct{}
	Client    *Client
}

GUI is chans for notifiing connected and finished.

func New

func New() *GUI

New returns a GUI struct.

func (*GUI) Emit

func (g *GUI) Emit(name string, dat interface{}, f interface{}) error

Emit emits "name" event with dat.

func (*GUI) Error

func (g *GUI) Error(err error)

Error emits an error message.

func (*GUI) On

func (g *GUI) On(n string, f interface{})

On registers handler for event n.

func (*GUI) Start

func (g *GUI) Start(dest, path string) error

Start starts GUI bakcend. Set dest to react debug server URL for redirecting to it. You must setup http.Handle before calling it.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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