项目作者: guark

项目描述 :
Build awesome Golang desktop apps and beautiful interfaces with Vue.js, React.js, Framework 7, and more...
高级语言: Go
项目地址: git://github.com/guark/guark.git
创建时间: 2020-04-14T18:29:54Z
项目社区:https://github.com/guark/guark

开源协议:MIT License

下载



Guark


Guark allows you to build beautiful user interfaces using modern web technologies such as Vue.js, React.js…, while your app logic handled and powered by the amazing Go.



Installation
Getting Started
Contributing
License


Guark Vue Template

🖳 About The Project

Guark is an open-source framework to build cross platform desktop GUI applications.

📢 What Guark stands for?

Go + Quark = Guark

🔮 Guark mission

Simplify cross platform desktop apps development.

🎸 How it works

Demo Video: https://youtu.be/_k_tq9sj-do

Guark backend and logic part handled by native Go code, while the user interfaces built with modern web technologies (Vue.js, React.js, etc…), and with Guark javascript API you can communicate between your Go and UI framework, and calling your exported Go functions and plugin(s) methods.

💌 Main Features

  • Desktop applications with GO ♥
  • One codebase for Gnu/Linux, macOS, and Windows.
  • UI Hot Reload.
  • You can use any front end framework.
  • Supports Chrome, and native webview engine or both.
  • Windows MSI bundler builtin.

📜 Installation

1. Install guark CLI tool:

  1. go install github.com/guark/guark/cmd/guark@latest

2. Some Requirements:

  1. // fedora
  2. sudo dnf install gtk3-devel webkit2gtk3-devel gcc-c++ pkgconf-pkg-config
  3. // Ubuntu
  4. sudo apt install libgtk-3-dev libwebkit2gtk-4.0-dev build-essential
  5. // Windows
  6. // https://jmeubank.github.io/tdm-gcc/download/

Open a console and make sure the tdm-gcc tools chain are in the PATH:

  1. gcc --version
  2. gcc (tdm64-1) 10.3.0
  3. Copyright (C) 2020 Free Software Foundation, Inc.
  4. This is free software; see the source for copying conditions. There is NO
  5. warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Getting Started

After installing guark CLI tool, the next step is to create a new guark project based on the template that you like:

Create a new project

  1. # cd to empty directory and run:
  2. guark init --template vue --mod github.com/username/appname

Start Dev Server

After creating new project run:

  1. guark run

Export your first GO function to JS API

1. Create a new file in lib/funcs directory:
  1. // lib/funcs/foo_bar.go
  2. import (
  3. "github.com/guark/guark/app"
  4. )
  5. func FooBar(c app.Context) (interface{}, error) {
  6. c.App.Log.Debug("Foo bar called")
  7. return "This is a my return value to javasript", nil
  8. }
2. Then export it to Guark JS API in lib/config.go file:
  1. // Exposed functions to guark Javascript api.
  2. var Funcs = app.Funcs{
  3. "foo": funcs.FooBar,
  4. }
3. Then you can call your function in javascript:
  1. import g from "guark"
  2. g.call("foo")
  3. .then(res => console.log(res))
  4. .catch(err => console.error(err))

See Vue template as an example: https://github.com/guark/vue

Guark Engines:

You can change the engine in guark.yaml file.

  • webview: Uses native system webview.
  • chrome: Uses and requires google chrome.
  • hybrid: Uses chrome if exists in the system, if chrome not available guark will switch to native webview by default.

Build Your App

Configure the build

guark-build.yaml contains all configuration and path required for the build, like the compilers or default platform.

The C/C++ compilers are not using the PATH environment and need an absolute path to them, on linux it will use the default paths for Linux builds.

For cross platform build, it will look like:

  1. linux:
  2. ldflags: ""
  3. darwin:
  4. ldflags: ""
  5. windows:
  6. cc: /usr/bin/x86_64-w64-mingw32-gcc
  7. cxx: /usr/bin/x86_64-w64-mingw32-g++
  8. ldflags: "-H windowsgui"
  9. windres: /usr/bin/x86_64-w64-mingw32-windres

Update these paths accordingly (check the GCC/distributions documentations for the right paths)

On Windows, make sure to have installed tdm-gcc, once done, update the guark-build.yaml:

  1. # Guark build config file.
  2. setup:
  3. - cmd: yarn install
  4. dir: ui
  5. - cmd: go mod download
  6. - cmd: go mod tidy
  7. - cmd: go mod verify
  8. linux:
  9. ldflags: ""
  10. darwin:
  11. ldflags: ""
  12. windows:
  13. cc: C:\apps\tdm-gcc1030\bin\gcc
  14. cxx: C:\apps\tdm-gcc1030\bin\g++
  15. ldflags: "-H windowsgui"
  16. windres: C:\apps\tdm-gcc1030\bin\windres.exe

Build

You can build your app with

  1. guark build

Bundle Windows App

After building your app you can bundle your windows app into msi using WIX.

  1. guark bundle

Wix required!

Install it from: https://wixtoolset.org/

Cross Compiling To Windows From Gnu/Linux:

You can build windows app from your linux based system, using mingw64

1. Install mingw64:

  1. // Fedora
  2. sudo dnf install mingw64-gcc
  3. // Ubuntu
  4. sudo apt install binutils-mingw-w64

2. Configure guark-build.yaml File:

Double check the binary paths in guark-build.yaml.

3. Build The App:

  1. # this command will build and compile linux, and windows app. you can find your compiled apps in `dist/` directory.
  2. guark build --target linux --target windows

You can use any cross compiler for example: guark build --target darwin. just change the options in guark-build.yaml file.

Note

You can also bundle windows app into MSI file from your linux based system via guark bundle, but you need to install wix tools:

  1. # fedora
  2. dnf install msitools
  3. # Ubuntu
  4. sudo apt-get install wixl

Contributing

PRs, issues, and feedback from ninja gophers are very welcomed.

License

Guark is provided under the MIT License.