All Projects → SimonWaldherr → Golibs

SimonWaldherr / Golibs

Licence: mit
general purpose Golang code (to be included in other projects)

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Golibs

LiteOTP
Multi OTP Spam Amp/Paralell threads
Stars: ✭ 50 (-56.14%)
Mutual labels:  package, libraries
flutter web import js library
Import & use javascript libraries in your flutter web projects
Stars: ✭ 28 (-75.44%)
Mutual labels:  package, libraries
awesome-kotlin-libraries-for-android
😎 A curated list of awesome Kotlin libraries for Android.
Stars: ✭ 53 (-53.51%)
Mutual labels:  libraries, examples
Rcppexamples
Examples of using Rcpp to interface R and C++
Stars: ✭ 33 (-71.05%)
Mutual labels:  examples, package
Vkbind
Single file Vulkan API loader.
Stars: ✭ 110 (-3.51%)
Mutual labels:  examples
Real World Ruby Apps
Real World Ruby apps and their open source codebases for developers to learn from
Stars: ✭ 107 (-6.14%)
Mutual labels:  examples
Go Examples
examples written using golang third party packages.
Stars: ✭ 106 (-7.02%)
Mutual labels:  examples
Gopherlabs
The Ultimate Workshop Track for #golang Developer
Stars: ✭ 106 (-7.02%)
Mutual labels:  examples
Angular Template For Threejs
Angular Template For Three.js
Stars: ✭ 114 (+0%)
Mutual labels:  examples
Repurrrsive
Recursive lists to use in teaching and examples, because there is no iris data for lists.
Stars: ✭ 112 (-1.75%)
Mutual labels:  package
Docusign Node Client
The Official DocuSign Node.js Client Library used to interact with the eSign REST API. Send, sign, and approve documents using this client.
Stars: ✭ 108 (-5.26%)
Mutual labels:  package
Rpi Examples
Raspberry Pi examples
Stars: ✭ 107 (-6.14%)
Mutual labels:  examples
Datepickertimelineflutter
Flutter Date Picker Library that provides a calendar as a horizontal timeline
Stars: ✭ 112 (-1.75%)
Mutual labels:  package
Rando Php
RandoPhp is a open source library that implements random generators (Integer, Char, Byte, Sequences, Boolean) and take random sample from arrays
Stars: ✭ 107 (-6.14%)
Mutual labels:  package
Elm Doc Preview
Elm offline documentation previewer
Stars: ✭ 113 (-0.88%)
Mutual labels:  package
Contracts
A set of reusable smart-contracts
Stars: ✭ 101 (-11.4%)
Mutual labels:  package
Logger json
JSON console backend for Elixir Logger.
Stars: ✭ 108 (-5.26%)
Mutual labels:  package
Headlesschrome
A Go package for working with headless Chrome. Run interactive JavaScript commands on web pages with Go and Chrome.
Stars: ✭ 112 (-1.75%)
Mutual labels:  package
Go Kafka Example
Golang Kafka consumer and producer example
Stars: ✭ 108 (-5.26%)
Mutual labels:  examples
Tensorflow Examples
TensorFlow Tutorial and Examples for Beginners (support TF v1 & v2)
Stars: ✭ 41,480 (+36285.96%)
Mutual labels:  examples

golibs

golang functions (to be included in other projects)

go get -u -t simonwaldherr.de/go/golibs/...

coverage & tests

go test ./...
. . service info
OSX Build Status Build Status go test ./...
Linux Build Status Travis CI travis-ci.org test on various go versions
Windows Build Status Appveyor CI appveyor.com test under windows
Linux Build Status Semaphore CI semaphoreci.com yet another ci service
Linux Build Status Wercker CI wercker.com the wercker ci service
Go Report Card goreportcard.com report card
codebeat badge codebeat.co code quality
Codacy Badge codacy.com code quality
BCH compliance bettercodehub.com code quality
Coverage Status coveralls.io test coverage
Coverage Status go tool cover
FOSSA Status fossa.io license report
License MIT free + open source license
Flattr donate button flattr.com micro donation
GoDoc godoc.org documentation

each new build gets tested in multiple steps:

  • on development i regularly type go test from time to time to check the test suite
  • also there are a few go apps in the examples-folder which i test to build and run
  • on commit, git automatically runs the pre-commit-hook shell script
  • after a commit gets pushed to GitHub, the following tests are started via Webhooks and Services
    • Travis CI build the lib and all tests on docker containers with the go versions noted in .travis.yml
    • appveyor builds the lib on Windows Server to test against the Microsoft Infrastructure (.appveyor.yml)
    • magnum-ci, another ci service build the lib and tests on a linux (ubuntu) machine
    • semaphoreci, yet another (linux (ubuntu) based) ci service

codecov.io

ToC

  • ansi can print colored and styled text to your terminal
  • arg simplifies cli flags (arguments)
  • as can convert most standard data types to most other data types
  • cache is an easy and small caching package
  • cachedfile simplifies reading and writing from and to disk and adds caching
  • channel simplifies channel operations, e.g. sending the same data to multiple receivers
  • csv load and parse CSV file
  • file wraps around the standard functions to simplify reading and writing on disk
  • foreach calls a given function for each element of a [ JSON-string ]
  • gcurses enabling the development of text user interface applications
  • gopath provides an easy way to get system information
  • graphics can manipulate images
  • log helps on logging your applications status
  • re helps you whenever you have to do something multiple times
  • regex is a layer to speed up your regular expression development
  • rss is a rss feed parser based on Golangs std xml package
  • ssl generates ssl certificates for https
  • stack can store your values in stacks and rings
  • structs use structs like maps
  • xmath provides a few mathematical functions like Sum, Median, Harmonic-mean, …
  • xtime xtime implements a subset of strftime

WARNING

some functions in this repo enables you to write really bad code - I wrote it anyway because:

  • sometimes you need a quick and dirty solution
  • it shows you possible ways, feel free to fork and customize
  • mostly bad go code is better than good php code - every aspect in golang is designed to prevent from bad code

BUT: please remember that you can do things more performantly e.g. converting a string to a float is much faster done with strconv.ParseFloat than with as.Float.

sublibs

ansi - GoDoc Coverage Status Build Status

import "simonwaldherr.de/go/golibs/ansi"

ansi can print colored and styled text to your terminal:

  • green, yellow and red strings:
log.Println(ansi.Color("INFO: everything is fine", ansi.Green))
log.Println(ansi.Color("WARNING: not everything is fine", ansi.Yellow))
log.Println(ansi.Color("ERROR: OMG!!!", ansi.Red))
  • bold and underlined text:
fmt.Printf("this is %v and %v text", ansi.Bold("bold"), ansi.Underline("underlined"))

arg - GoDoc Coverage Status Build Status

import "simonwaldherr.de/go/golibs/arg"

the arg package simplifies cli flags (arguments)

as - GoDoc Coverage Status Build Status

import "simonwaldherr.de/go/golibs/as"

with as you can convert most standard data types to most other data types e.g.

  • int to string:
var x string = as.String(int(32))
  • string to int:
var x int = as.Int("32")
  • string to time:
var x time.Time = as.Time("31.12.2014")

cache - GoDoc Coverage Status Build Status

import "simonwaldherr.de/go/golibs/cache"

cachedfile - GoDoc Coverage Status Build Status

import "simonwaldherr.de/go/golibs/cachedfile"

cachedfile simplifies reading and writing from and to disk and adds caching

do

str := "Neque porro quisquam est, qui dolorem ipsum, quia dolor sit, amet, consectetur, adipisci velit."
err := cachedfile.Write("filename.txt", str, false)

and in less then 15 minutes this

str, _ := cachedfile.Read("filename.txt")

and there will be no file access to disk. If you kill the App, wait 15 min or call cachedfile.Stop() the cached content will be exported to disk.

channel - GoDoc Coverage Status Build Status

import "simonwaldherr.de/go/golibs/channel"

channel simplifies channel operations, e.g. sending the same data to multiple receivers

con := channel.Init()

receiver01 := con.AddReceiver()
receiver02 := con.AddReceiver()
receiver03 := con.AddReceiver()

go func() {
  fmt.Println(<-receiver01)
}()

go func() {
  fmt.Println(<-receiver02)
}()

go func() {
  fmt.Println(<-receiver03)
}()

transmitter01 := con.AddTransmitter()

transmitter01 <- "Hello World"

csv - GoDoc Coverage Status Build Status

import "simonwaldherr.de/go/golibs/csv"

file - GoDoc Coverage Status Build Status

import "simonwaldherr.de/go/golibs/file"

file wraps around the standard functions to simplify reading and writing on disk

str := "Neque porro quisquam est, qui dolorem ipsum, quia dolor sit, amet, consectetur, adipisci velit."
err := file.Write("filename.txt", str, false)

Besides simple reading and writing, the package also contains functions to test file statuses, read large files by small blocks, clear, rename and delete files. There is even a function for do things with each file in a directory (even with subfolders):

err := file.Each("..", true, func(filename, extension, filepath string, dir bool, fileinfo os.FileInfo) {
	if extension == "go" && !dir {
		t.Logf("%v, %v, %v, %v\n", filename, filepath, dir, fileinfo)
	}
}

If you need the absolute path to a file, but only have a relative path, you can use file.GetAbsolutePath("~/path/to/file.txt").

foreach - GoDoc Coverage Status Build Status

import "simonwaldherr.de/go/golibs/foreach"

foreach calls a given function for each element of a [ JSON-string ]

gcurses - GoDoc Coverage Status Build Status

import "simonwaldherr.de/go/golibs/gcurses"

gcurses is a terminal control library for Unixoide systems, enabling the development of text user interface applications.

Named after the "GUI-like" terminal application toolkit ncurses (new curses) which is named after the original curses. This library is in a very early stage.

package main

import (
  "fmt"
  "simonwaldherr.de/go/golibs/gcurses"
  "time"
)

func main() {
  writer := gcurses.New()

  writer.Start()

  for i := 0; i < 100; i++ {
    fmt.Fprintf(writer, "Count till one hundred: %d\nStill counting ...\n", i)
    time.Sleep(time.Millisecond * 10)
  }

  time.Sleep(time.Millisecond * 500)
  fmt.Fprintln(writer, "Finished counting")

  writer.Stop()
}

gopath - GoDoc Coverage Status Build Status

import "simonwaldherr.de/go/golibs/gopath"

gopath provides an easy way to get system information

to read a config file in which is in the same file as the executable, you can do something like this:

package main

import (
  "fmt"
  "path/filepath"
  "simonwaldherr.de/go/golibs/file"
  "simonwaldherr.de/go/golibs/gopath"
)

func main() {
  dir := gopath.Dir()
  config := file.Read(filepath.Join(dir, "config.yaml"))
  
  ...

graphics - GoDoc Coverage Status Build Status

import "simonwaldherr.de/go/golibs/graphics"

with graphics you can manipulate images

img := graphics.EachPixel(file, func(r, g, b, a uint8) (uint8, uint8, uint8, uint8) {
	return g, b, r, a
})

log - GoDoc Coverage Status Build Status

import "simonwaldherr.de/go/golibs/log"

re - GoDoc Coverage Status Build Status

import "simonwaldherr.de/go/golibs/re"

re helps you whenever you have to do something multiple times

data, stop := re.Do(time.Second * 5, func(data chan<- interface{}) {
	data <- fmt.Sprintf("%v\n", time.Now().Format("02.01.2006 15:04:05"))
})

regex - GoDoc Coverage Status Build Status

import "simonwaldherr.de/go/golibs/regex"

regex is a layer to speed up your regular expression development

str, err := regex.ReplaceAllString("Ipsum Lorem", "([^ ]+) ([^ ]+)", "$2 $1")

rss - GoDoc Coverage Status Build Status

import "simonwaldherr.de/go/golibs/rss"

rss is a rss feed parser based on Golangs std xml package

podcast, err := rss.Read(url)
if err == nil {
  for _, episode := range podcast.Items {
    fmt.Println(episode.Title)
  }
}

ssl - GoDoc Coverage Status Build Status

import "simonwaldherr.de/go/golibs/ssl"

ssl generates ssl certificates for https

err := ssl.Generate(options)

stack - GoDoc Coverage Status Build Status

import "simonwaldherr.de/go/golibs/stack"

with stack you can store your values in stacks and rings

array := stack.Lifo()
array.Push(as.Bytes(12.34))
array.Push(as.Float(13.37))
array.Push(as.String(23.0))
for array.Len() > 0 {
	log.Println(array.Pop())
}

structs - GoDoc Coverage Status Build Status

import "simonwaldherr.de/go/golibs/structs"

xmath - GoDoc Coverage Status Build Status

import "simonwaldherr.de/go/golibs/xmath"

xmath provides a few mathematical functions like Max, Min, Sum, Median, Harmonic-mean, ...

var f = []float64{.5, 1.33, 2.66, 3.99, 13.37, 23.42, 42.000003}

fmt.Printf("Max: %v\n", xmath.Max(f))
fmt.Printf("Min: %v\n", xmath.Min(f))
fmt.Printf("Sum: %v\n", xmath.Sum(f))

fmt.Printf("Median:     %v\n", xmath.Median(f))
fmt.Printf("Arithmetic: %v\n", xmath.Arithmetic(f))
fmt.Printf("Harmonic:   %v\n", xmath.Harmonic(f))
fmt.Printf("Geometric:  %v\n", xmath.Geometric(f))

xtime - GoDoc Coverage Status Build Status

import "simonwaldherr.de/go/golibs/xtime"

xtime implements a subset of strftime

t, _ := time.Now()
fmt.Println(xtime.Fmt("%Y-%m-%d %H:%M:%S", t))
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].