1642077420
Prometheus Go client library
This is the Go client library for Prometheus. It has two separate parts, one for instrumenting application code, and one for creating clients that talk to the Prometheus HTTP API.
This library requires Go1.13 or later.
This repository generally follows Semantic Versioning. However, the API client in prometheus/client_golang/api/… is still considered experimental. Breaking changes of the API client will not trigger a new major release. The same is true for selected other new features explicitly marked as EXPERIMENTAL in CHANGELOG.md.
Features that require breaking changes in the stable parts of the repository are being batched up and tracked in the v2 milestone. The v2 development happens in a separate branch for the time being. v2 releases off that branch will happen once sufficient stability is reached. In view of the widespread use of this repository, v1 and v2 will coexist for a while to enable a convenient transition.
The prometheus
directory contains the instrumentation library. See the guide on the Prometheus website to learn more about instrumenting applications.
The examples
directory contains simple examples of instrumented code.
The api/prometheus
directory contains the client for the Prometheus HTTP API. It allows you to write Go applications that query time series data from a Prometheus server. It is still in alpha stage.
model
, extraction
, and text
?The model
packages has been moved to prometheus/common/model
.
The extraction
and text
packages are now contained in prometheus/common/expfmt
.
See the contributing guidelines and the Community section of the homepage.
Author: Prometheus
Source Code: https://github.com/prometheus/client_golang
License: Apache-2.0 License
1599854400
Go announced Go 1.15 version on 11 Aug 2020. Highlighted updates and features include Substantial improvements to the Go linker, Improved allocation for small objects at high core counts, X.509 CommonName deprecation, GOPROXY supports skipping proxies that return errors, New embedded tzdata package, Several Core Library improvements and more.
As Go promise for maintaining backward compatibility. After upgrading to the latest Go 1.15 version, almost all existing Golang applications or programs continue to compile and run as older Golang version.
#go #golang #go 1.15 #go features #go improvement #go package #go new features
1597848999
Created by Google researchers, Go is a popular open-source programming language. The language includes many intuitive features, including a garbage collector, cross-platform, efficient concurrency, among others.
According to the Stack Overflow Developer Survey 2020, Go language is not only the fifth most loved programming language but also fetches the programmers the third-highest salary among other languages.
Below here, we list down the top machine learning libraries in Go language.
#opinions #go language #google ml tools #machine learning libraries #ml libraries #ml libraries in go
1642077420
Prometheus Go client library
This is the Go client library for Prometheus. It has two separate parts, one for instrumenting application code, and one for creating clients that talk to the Prometheus HTTP API.
This library requires Go1.13 or later.
This repository generally follows Semantic Versioning. However, the API client in prometheus/client_golang/api/… is still considered experimental. Breaking changes of the API client will not trigger a new major release. The same is true for selected other new features explicitly marked as EXPERIMENTAL in CHANGELOG.md.
Features that require breaking changes in the stable parts of the repository are being batched up and tracked in the v2 milestone. The v2 development happens in a separate branch for the time being. v2 releases off that branch will happen once sufficient stability is reached. In view of the widespread use of this repository, v1 and v2 will coexist for a while to enable a convenient transition.
The prometheus
directory contains the instrumentation library. See the guide on the Prometheus website to learn more about instrumenting applications.
The examples
directory contains simple examples of instrumented code.
The api/prometheus
directory contains the client for the Prometheus HTTP API. It allows you to write Go applications that query time series data from a Prometheus server. It is still in alpha stage.
model
, extraction
, and text
?The model
packages has been moved to prometheus/common/model
.
The extraction
and text
packages are now contained in prometheus/common/expfmt
.
See the contributing guidelines and the Community section of the homepage.
Author: Prometheus
Source Code: https://github.com/prometheus/client_golang
License: Apache-2.0 License
1663306680
In today's post we will learn about 10 Favorite Libraries for Building GUI Applications in Go.
What is the GUI application?
A graphical user interface (GUI) application is one that is designed using graphical features such as windows, menus, dialog boxes, and features that make the application easy to use. When you compile a GUI application, an executable file with start-up code is created.
Table of contents:
Go-app is a package for building progressive web apps (PWA) with the Go programming language (Golang) and WebAssembly (Wasm).
Shaping a UI is done by using a declarative syntax that creates and compose HTML elements only by using the Go programing language.
It uses Go HTTP standard model.
An app created with go-app can out of the box run in its own window, supports offline mode, and are SEO friendly.
go-app requirements:
go mod init go get -u github.com/maxence-charriere/go-app/v9/pkg/app
Go-app uses a 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:
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)),
),
)
}
Apps created with go-app complies with Go standard HTTP package interfaces.
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)
}
}
About
Fyne is an easy-to-use UI toolkit and app API written in Go. It is designed to build applications that run on desktop and mobile devices with a single codebase.
Version 2.2 is the current release of the Fyne API, it added system tray support, App.Metadata
as well as richer menus and support for building WASM apps. We are now working towards the next big release, codenamed cragganmore and more news will follow in our news feeds and GitHub project.
Prerequisites
To develop apps using Fyne you will need Go version 1.14 or later, a C compiler and your system's development tools. If you're not sure if that's all installed or you don't know how then check out our Getting Started document.
Using the standard go tools you can install Fyne's core library using:
$ go get fyne.io/fyne/v2
Widget demo
To run a showcase of the features of Fyne execute the following:
$ go get fyne.io/fyne/v2/cmd/fyne_demo/
$ fyne_demo
Getting Started
Fyne is designed to be really easy to code with. If you have followed the prerequisite steps above then all you need is a Go IDE (or a text editor).
Open a new file and you're ready to write your first app!
package main
import (
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
)
func main() {
a := app.New()
w := a.NewWindow("Hello")
hello := widget.NewLabel("Hello Fyne!")
w.SetContent(container.NewVBox(
hello,
widget.NewButton("Hi!", func() {
hello.SetText("Welcome :)")
}),
))
w.ShowAndRun()
}
And you can run that simply as:
$ go run main.go
It should look like this:
![]() | ![]() |
Note that Windows applications load from a command prompt by default, which means if you click an icon you may see a command window. To fix this add the parameters
-ldflags -H=windowsgui
to your run or build commands.
There is a helpful mobile simulation mode that gives a hint of how your app would work on a mobile device:
$ go run -tags mobile main.go
Another option is to use fyne
command, see Packaging for mobile.
Installing
Using go install
will copy the executable into your go bin
dir. To install the application with icons etc into your operating system's standard application location you can use the fyne utility and the "install" subcommand.
$ go get fyne.io/fyne/v2/cmd/fyne
$ fyne install
This is a library that aims to provide simple GUI software development in Go. It is based on my libui, a simple cross-platform library that does the same thing, but written in C.
It runs on/requires:
sudo apt-get install libgtk-3-dev
sudo dnf install gtk3-devel
It also requires Go 1.8 or newer.
It currently aligns to libui's Alpha 4.1, with only a small handful of functions not available.
Status
Package ui is currently mid-alpha software. Much of what is currently present runs stabily enough for the examples and perhaps some small programs to work, but the stability is still a work-in-progress, much of what is already there is not feature-complete, some of it will be buggy on certain platforms, and there's a lot of stuff missing. The libui README has more information.
Installation
Once you have the dependencies installed, a simple
go get github.com/andlabs/ui/...
should suffice.
Documentation
The in-code documentation is sufficient to get started, but needs improvement.
Some simple example programs are in the examples
directory. You can go build
each of them individually.
Package ui requires a manifest that specifies Common Controls v6 to run on Windows. It should at least also state as supported Windows Vista and Windows 7, though to avoid surprises with other packages (or with Go itself; see this issue) you should state compatibility with higher versions of Windows too.
The simplest option is provided as a subpackage winmanifest
; you can simply import it without a name, and it'll set things up properly:
import _ "github.com/andlabs/ui/winmanifest"
You do not have to worry about importing this in non-Windows-only files; it does nothing on non-Windows platforms.
If you wish to use your own manifest instead, you can use the one in winmanifest
as a template to see what's required and how. You'll need to specify the template in a .rc
file and use windres
in MinGW-w64 to generate a .syso
file as follows:
windres -i resources.rc -o winmanifest_windows_GOARCH.syso -O coff
You may also be interested in the github.com/akavel/rsrc
and github.com/josephspurrier/goversioninfo
packages, which provide other Go-like options for embedding the manifest.
Note that if you choose to ship a manifest as a separate .exe.manifest
file instead of embedding it in your binary, and you use Cygwin or MSYS2 as the source of your MinGW-w64, Cygwin and MSYS2 instruct gcc to embed a default manifest of its own if none is specified. This default will override your manifest file! See this issue for more details, including workaround instructions.
Thanks to go-astilectron
build cross platform GUI apps with GO and HTML/JS/CSS. It is the official GO bindings of astilectron and is powered by Electron.
Demo
To see a minimal Astilectron app, checkout out the demo.
It uses the bootstrap and the bundler.
If you're looking for a minimalistic example, run go run example/main.go -v
.
Real-life examples
Here's a list of awesome projects using go-astilectron
(if you're using go-astilectron
and want your project to be listed here please submit a PR):
Bootstrap
For convenience purposes, a bootstrap has been implemented.
The bootstrap allows you to quickly create a one-window application.
There's no obligation to use it, but it's strongly recommended.
If you decide to use it, read thoroughly the documentation as you'll have to structure your project in a specific way.
Bundler
Still for convenience purposes, a bundler has been implemented.
The bundler allows you to bundle your app for every os/arch combinations and get a nice set of files to send your users.
Quick start
WARNING: the code below doesn't handle errors for readibility purposes. However you SHOULD!
go-astilectron
To import go-astilectron
run:
$ go get -u github.com/asticode/go-astilectron
go-astilectron
// Initialize astilectron
var a, _ = astilectron.New(log.New(os.Stderr, "", 0), astilectron.Options{
AppName: "<your app name>",
AppIconDefaultPath: "<your .png icon>", // If path is relative, it must be relative to the data directory
AppIconDarwinPath: "<your .icns icon>", // Same here
BaseDirectoryPath: "<where you want the provisioner to install the dependencies>",
VersionAstilectron: "<version of Astilectron to utilize such as `0.33.0`>",
VersionElectron: "<version of Electron to utilize such as `4.0.1` | `6.1.2`>",
})
defer a.Close()
// Start astilectron
a.Start()
// Blocking pattern
a.Wait()
For everything to work properly we need to fetch 2 dependencies : astilectron and Electron. .Start()
takes care of it by downloading the sources and setting them up properly.
In case you want to embed the sources in the binary to keep a unique binary you can use the NewDisembedderProvisioner function to get the proper Provisioner and attach it to go-astilectron
with .SetProvisioner(p Provisioner)
. Or you can use the bootstrap and the bundler. Check out the demo to see how to use them.
Beware when trying to add your own app icon as you'll need 2 icons : one compatible with MacOSX (.icns) and one compatible with the rest (.png for instance).
If no BaseDirectoryPath is provided, it defaults to the executable's directory path.
The majority of methods are asynchronous which means that when executing them go-astilectron
will block until it receives a specific Electron event or until the overall context is cancelled. This is the case of .Start()
which will block until it receives the app.event.ready
astilectron
event or until the overall context is cancelled.
About Walk
Walk is a "Windows Application Library Kit" for the Go Programming Language.
Its primarily useful for Desktop GUI development, but there is some more stuff.
Setup
Make sure you have a working Go installation. See Getting Started
Note
Walk currently requires Go 1.11.x or later.
To Install
Now run go get github.com/lxn/walk
Using Walk
The preferred way to create GUIs with Walk is to use its declarative sub package, as illustrated in this small example:
test.go
package main
import (
"github.com/lxn/walk"
. "github.com/lxn/walk/declarative"
"strings"
)
func main() {
var inTE, outTE *walk.TextEdit
MainWindow{
Title: "SCREAMO",
MinSize: Size{600, 400},
Layout: VBox{},
Children: []Widget{
HSplitter{
Children: []Widget{
TextEdit{AssignTo: &inTE},
TextEdit{AssignTo: &outTE, ReadOnly: true},
},
},
PushButton{
Text: "SCREAM",
OnClicked: func() {
outTE.SetText(strings.ToUpper(inTE.Text()))
},
},
},
}.Run()
}
Create Manifest test.manifest
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="SomeFunkyNameHere" type="win32"/>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
</dependentAssembly>
</dependency>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">True</dpiAware>
</windowsSettings>
</application>
</assembly>
Go bindings for Sciter
Check this page for other language bindings (Delphi / D / Go / .NET / Python / Rust).
Attention
The ownership of project is transferred to this new organization. Thus the import path
for golang should now be github.com/sciter-sdk/go-sciter
, but the package name is still sciter
.
Introduction
This package provides a Golang bindings of Sciter using cgo. Using go sciter you must have the platform specified sciter dynamic library
downloaded from sciter-sdk, the library itself is rather small (under 5MB, less than 2MB when upxed) .
Most Sciter API are supported, including:
And the API are organized in more or less a gopher friendly way.
Things that are not supported:
Getting Started
Download the sciter-sdk
Extract the sciter runtime library from sciter-sdk to system PATH
The runtime libraries lives in bin
bin.lnx
bin.osx
with suffix like dll
so
or dylib
bin\64\sciter.dll
to c:\windows\system32
is just enoughcd sciter-sdk/bin.lnx/x64
export LIBRARY_PATH=$PWD
echo $PWD >> libsciter.conf
sudo cp libsciter.conf /etc/ld.so.conf.d/
sudo ldconfig
ldconfig -p | grep sciter
should print libsciter-gtk.so locationcd sciter-sdk/bin.osx/
export DYLD_LIBRARY_PATH=$PWD
Set up GCC envrionmnet for CGO
mingw64-gcc (5.2.0 and 7.2.0 are tested) is recommended for Windows users.
Under Linux gcc(4.8 or above) and gtk+-3.0 are needed.
go get -x github.com/sciter-sdk/go-sciter
Run the example and enjoy :)
html5tag
The html5tag package contains utilities to generate html 5 tags. Choose between string versions of the functions for easy tag creation, or io.Writer versions for speed.
html5tag also has a tag builder for convenience and can perform math operations on numeric style values.
html5tag does some checks to make sure tags are well-formed. For example, when adding data-* attributes, it will make sure the key used for the attribute does not violate html syntax rules.
html5tag has options to pretty-print tags and the content of tags so they appear formatted in a document. However, in certain contexts, like in inline text, or in a textarea tag, adding extra returns and spaces changes the look of the output. In these situations, use the functions that do not add spaces to the inner HTML of a tag.
Some examples:
package main
import . "github.com/goradd/html5tag"
main() {
// Render an input tag, inside a div tag, inside a body tag using different tag building mechanisms
a := NewAttributes().
SetID("myText").
Set("text", "Hi there").
Set("placeholder", "Write here").
SetClass("class1 class2").
SetStyle("width":"20em")
inputTag := RenderVoidTag("input", a)
divTag := RenderTag("div", Attriubtes{"id":"inputWrapper"}, inputTag)
bodyTag := NewTagBuilder().
Tag("body").
ID("bodyId").
InnerHtml(divTag).
String()
fmt.Print(bodyTag)
}
For complete documentation, start at the documentation for RenderTag()
and WriteTag()
and drill down from there.
The gotk3 project provides Go bindings for GTK 3 and dependent projects. Each component is given its own subdirectory, which is used as the import path for the package. Partial binding support for the following libraries is currently implemented:
Care has been taken for memory management to work seamlessly with Go's garbage collector without the need to use or understand GObject's floating references.
for better understanding see package reference documation
On Linux, see which version your distribution has here with the search terms:
The following example can be found in Examples.
package main
import (
"github.com/gotk3/gotk3/gtk"
"log"
)
func main() {
// Initialize GTK without parsing any command line arguments.
gtk.Init(nil)
// Create a new toplevel window, set its title, and connect it to the
// "destroy" signal to exit the GTK main loop when it is destroyed.
win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
if err != nil {
log.Fatal("Unable to create window:", err)
}
win.SetTitle("Simple Example")
win.Connect("destroy", func() {
gtk.MainQuit()
})
// Create a new label widget to show in the window.
l, err := gtk.LabelNew("Hello, gotk3!")
if err != nil {
log.Fatal("Unable to create label:", err)
}
// Add the label to the window.
win.Add(l)
// Set the default window size.
win.SetDefaultSize(800, 600)
// Recursively show all widgets contained in this window.
win.ShowAll()
// Begin executing the GTK main loop. This blocks until
// gtk.MainQuit() is run.
gtk.Main()
}
To build the example:
$ go build example.go
To build this example with older gtk version you should use gtk_3_10 tag:
$ go build -tags gtk_3_10 example.go
Build cross platform GUI apps with GO and HTML/JS/CSS (powered by nwjs)
Download and install nwjs
Install this library go get github.com/dtylman/gowd
Clone this repo.
Place package.json
, index.html
, main.go
and main.js
from template in a new folder.
go build
Edit main.js
and set goBinary
to your your executable name:
var goBinary = "./template"; //or template.exe
Run nw .
, the hello world template should appear:
Simplest "hello world":
import "github.com/dtylman/gowd"
func main() {
body, err := gowd.ParseElement("<h1>Hello world</h1>", nil)
if err != nil {
panic(err)
}
gowd.Run(body)
}
Adding a button:
import (
"github.com/dtylman/gowd"
)
func main() {
body, err := gowd.ParseElement("<h1>Hello world</h1>", nil)
if err != nil {
panic(err)
}
p := body.AddElement(gowd.NewElement("p"))
btn := p.AddElement(gowd.NewElement("button"))
btn.SetText("Click me")
btn.OnEvent(gowd.OnClick, btnClicked)
gowd.Run(body)
}
func btnClicked(sender *gowd.Element, event *gowd.EventElement) {
sender.SetText("Clicked!")
}
Qt is a free and open-source widget toolkit for creating graphical user interfaces as well as cross-platform applications that run on various software and hardware platforms with little or no change in the underlying codebase.
Go, also known as Golang, is a programming language designed at Google.
therecipe/qt allows you to write Qt applications entirely in Go, JavaScript/TypeScript, Dart/Flutter, Haxe and Swift
Beside the language bindings provided, therecipe/qt
also greatly simplifies the deployment of Qt applications to various software and hardware platforms.
At the time of writing, almost all Qt functions and classes are accessible, and you should be able to find everything you need to build fully featured Qt applications.
Gallery of example applications.
The following instructions assume that you already installed Go and Git
Windows
go get -ldflags="-w" github.com/therecipe/examples/basic/widgets && for /f %v in ('go env GOPATH') do %v\bin\widgets.exe
macOS/Linux
go get -ldflags="-w" github.com/therecipe/examples/basic/widgets && $(go env GOPATH)/bin/widgets
Windows (more info)
set GO111MODULE=off
go get -v github.com/therecipe/qt/cmd/... && for /f %v in ('go env GOPATH') do %v\bin\qtsetup test && %v\bin\qtsetup -test=false
macOS (more info)
export GO111MODULE=off; xcode-select --install; go get -v github.com/therecipe/qt/cmd/... && $(go env GOPATH)/bin/qtsetup test && $(go env GOPATH)/bin/qtsetup -test=false
Linux (more info)
export GO111MODULE=off; go get -v github.com/therecipe/qt/cmd/... && $(go env GOPATH)/bin/qtsetup test && $(go env GOPATH)/bin/qtsetup -test=false
Thank you for following this article.
Create GUI Apps with Go | Fyne Toolkit | Awesome Go
1655304840
Building Web Applications with Go
Welcome, gopher! You're not a gopher? Well, this workshop is for gophers, or people that use the Go programming language. But fear not if you've never written any Go before! I'd recommend you learn the basics for the language first with the Go tour.
This workshop has been run a couple of times with an instructor leading. The goal of this repo is to make it as easy as possible for individuals to follow the content by themselves. If you get stuck at any point, feel free to file issues asking questions.
To go through this you will need the following:
GOPATH
by following the How to Write Go Code tutorial.There's a lot to say about how to build web applications, in Go or any other language. But we only have one day so we won't try to cover too much. Instead we'll cover the basics, so you'll be able to explore other solutions and frameworks later.
The workshops is divided in eleven sections:
These are places where you can find more information for Go:
My favorite aspect of Go is its community, and you are now part of it too. Welcome!
As a newcomer to the Go community you might have questions or get blocked at some point. This is completely normal, and we're here to help you. Some of the places where gophers tend to hang out are:
This is not an official Google product (experimental or otherwise), it is just code that happens to be owned by Google.
Author: Campoy
Source Code: https://github.com/campoy/go-web-workshop
License: Apache-2.0 license