• Stars
    star
    121
  • Rank 293,924 (Top 6 %)
  • Language
    Go
  • License
    MIT License
  • Created over 10 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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
Audit github.com test via GitHub Workflow
Travis CI travis-ci.com test at travis-ci
Build Status semaphoreci.com test at semaphore-ci
Go Report Card goreportcard.com report card
codebeat badge codebeat.co 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
GoDoc godoc.org documentation
GoDoc godoc @ github.io documentation
DOI zenodo.org Digital Object Identifier

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
    • semaphoreci, yet another (linux (ubuntu) based) ci service

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
  • bitmask set and get bits in a bitmask
  • 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
  • http make easy and fast HTTP(S) requests
  • 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")

bitmask - GoDoc Coverage Status Build Status

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

with bitmask you can set and get bits to and from a bitmask:

i := bitmask.New(0b11111111)
i.Set(0, false)

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
})

you even can apply filters to images:

file, _ := os.Open("./original.png")
defer file.Close()

img, _, err := image.Decode(file)

img = Edgedetect(img)

out, _ := os.Create("./edgeDetect.png")

png.Encode(out, img)
fd.Close()

http - GoDoc Coverage Status Build Status

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

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))

More Repositories

1

golang-examples

Go(lang) examples - (explain the basics of #golang)
Go
1,498
star
2

GoRealtimeWeb

Examples how to write realtime web applications in Golang
Go
220
star
3

micromarkdown.js

convert markdown to html in under 5kb
JavaScript
207
star
4

GolangSortingVisualization

examples of various sorting algorithms in golang (with visualization)
Go
122
star
5

golang-benchmarks

Go(lang) benchmarks - (measure the speed of golang)
Go
116
star
6

passkit.php

a php function to create passes for Apple Passbook
PHP
61
star
7

PullToRefresh

a JavaScript implementation of PullToRefresh without jQuery or other Frameworks under MIT-License
HTML
57
star
8

HowTo-Deploy-LaTeX-Documents

Deploy LaTeX (and Markdown) Documents as PDF (and DjVu) via GitHub and TravisCI
TeX
49
star
9

ColorConverter.js

Convert between RGB, YUV, HSL, CMYK and HEX color defining with these JavaScript functions under MIT-License
HTML
45
star
10

zplgfa

#Golang package and cli tool for converting to #ZPL (from PNG, JPEG and GIF) for @ZebraTechnology-printers
Go
43
star
11

infinity.js

infinity.js adds infinite scrolling to webpages
JavaScript
43
star
12

cgolGo

Conway's Game of Life in Golang
Go
41
star
13

selfCSS

a CSS3 WYSIWYG Editor/Generator (in HTML5, CSS3 and JS)
JavaScript
35
star
14

disTime.js

converts UNIX-Timestamps to strings like " 5 days ago " in 19 languages
JavaScript
35
star
15

konami.js

logs every keypress and store it for later
JavaScript
34
star
16

parseTime.js

convert strings like "five days ago" to an integer (with time in seconds)
JavaScript
31
star
17

imgResize.js

smart resize images in a HTML5 Canvas
JavaScript
24
star
18

bbmandelbrotGo

generate images of a mandelbrot fractal
Go
20
star
19

wikiGo

mini wiki software in golang
Go
20
star
20

ups

Uncommon Printing System
Go
18
star
21

majaX.js

majaX stands for micro asynchronous javascript and X (X stands for XML, JSON, CSV, Plaintext, ...)
CoffeeScript
17
star
22

goCal

experimental #CalDAV + #WebCal Server in #Golang
Go
16
star
23

gwv

Golang Web Valve - to be connected to your series of tubes
Go
16
star
24

saprfc

call SAP ABAP Code from Golang (Remote Function Call)
Go
15
star
25

CSSfilter.js

CSSfilter.js helps you, adding CSS filters to images (or other elements)
JavaScript
14
star
26

fsagent

watch a folder for new or modified files and do something (copy, move, delete, send via mail, ...)
Go
13
star
27

golang-minigames

Go
12
star
28

cryptofoo

a good compromise between speed and validity to hash strings
JavaScript
10
star
29

sql-examples

sql examples (sqlite)
9
star
30

uploader

Multiple file upload plugin with progress-bar, drag-and-drop
JavaScript
7
star
31

ColorConverterGo

Convert between RGB, HSL and HEX color defining with these GO functions under MIT-License
Go
6
star
32

micromarkdown.php

https://github.com/SimonWaldherr/micromarkdown.js translated to php
PHP
6
star
33

se16jsonify

access SAP Database Tables and RFC-able Functions | example
Go
6
star
34

wp-osf-shownotes

simplifies Show Notes, write them in OSF, get them as HTML
CSS
6
star
35

DOMpteur

play with the Document Object Model (DOM) tree
JavaScript
5
star
36

micromarkdownGo

https://github.com/SimonWaldherr/micromarkdown.js translated to golang
Go
5
star
37

phpmd

convert md to html via php and regex
PHP
5
star
38

ScrapeEMS

ScrapeEMS is a #golang #cli tool to scrape the EMS (#ELDIS Management Suite)
Go
4
star
39

loginCtrl

a easy to use, free login system. (PHP, JS, SQLite/MySQL)
PHP
4
star
40

ircLogger.go

Go
4
star
41

rpi-examples

Raspberry Pi Golang Examples
Go
4
star
42

podlovejs

Podlove Web Player TNG – for internal bastelling only.
JavaScript
4
star
43

ColorConverter.php

Convert between RGB, HSL and HEX color defining with these PHP function under MIT-License
PHP
4
star
44

FormMate

FormMate is a Framework for making web forms
JavaScript
3
star
45

liveCalc

having fun with arithmetic
HTML
3
star
46

telnet2http.go

telnet server and http client in golang
Go
3
star
47

OTP-CAPTCHA

OneTimePad-Completely Automated Public Turing test to tell Computers and Humans Apart
PHP
3
star
48

Arduino-sketchbook

My Arduino sketches on GitHub
Arduino
3
star
49

Target3001-templates-and-examples

templates and examples for Target3001!
3
star
50

ranger

generates regexp code for numeric ranges
Go
3
star
51

canvastools.js

tools for a html5 canvas
JavaScript
3
star
52

colorize.js

converts integer to color
JavaScript
3
star
53

FluidSimASCII

This is a Golang fluid simulator using the "Smoothed-particle hydrodynamics (SPH)" method
Go
3
star
54

listDnD

sort lists via Drag and Drop. This is a fork from tool-man.org
JavaScript
3
star
55

easySQL

a database wrapper for easy read and write actions on a sql db (SQLite, MySQL, PostgreSQL, ...)
PHP
2
star
56

node.js-example

an example how to use node.js as a webserver
JavaScript
2
star
57

OSF.php

a repo for the main-code of the OSF parser (to include in other projects)
PHP
2
star
58

cgol.rs

Conway's Game of Life in Rust
Rust
2
star
59

BaF-Framework

HTML buttons and forms (since baf 2.0)
JavaScript
2
star
60

podlove-font

Shell
2
star
61

CocktailTDI

PHP
2
star
62

CalCalc.js

JavaScript functions to calculate calendars
HTML
2
star
63

FOJSLC

Free Open JavaScript Lib Collection
JavaScript
2
star
64

hx711go

Golang package to interface hx711 load cell amplifier
Go
2
star
65

tcial.js

the cake is a lie, but the cookie isn't
JavaScript
1
star
66

str2ascii

text to ascii and reverse
PHP
1
star
67

DSV

An easy to use collection of php functions to deal with DSV files. Convert DSV files to a 2D Array, RSS-Feed, Atom-Feed, .htaccess, .htpasswd, HTML, FEA, ...
PHP
1
star
68

GameOfLife

multiple implementations of Conway's Game of Life
Java
1
star
69

pico75player

play animated GIFs on a Hub75 Matrix with Raspberry Pi Pico (Pimoroni Interstate 75)
Go
1
star
70

DIY-Arcade-Machine

my very own arcade machine
Python
1
star
71

lightbox.js

a free, easy to use, tiny, jquery free lightbox script
JavaScript
1
star
72

go-wiki

mirror of the github golang wiki
1
star
73

Datanalyze

1
star
74

ScreenShare2040

Draw via browser, upload images and screen-share to a RGB-LED-Matrix
HTML
1
star
75

git-iso-29500

Dieses Dokument dient zur Eruierung der Praktikabilität von Git-Hooks zur Git-ifizierung von .docx-Dateien
Shell
1
star
76

SimonWaldherr

1
star
77

movingavg

In statistics, a moving average is a calculation to analyze data points by creating a series of averages of different subsets of the full data set. #golang
Go
1
star
78

mySlid.es

a impress.js editor
PHP
1
star
79

BookTemplate

automate your document generation process
Nix
1
star
80

podlove-templates

Templates for the Podlove Publisher
HTML
1
star
81

data-href

ajax for normal links
JavaScript
1
star
82

sapUserManager

SAP User Copy via BAPIs
Go
1
star
83

rp2040-examples

Examples for Raspberry Pi Pico (RP2040 MCU based SBCs)
Python
1
star
84

ColorConverter.swift

Swift
1
star
85

dotfiles

my dotfiles
Shell
1
star
86

tableCtrl

make, modify, manage, export and delete HTML tables
JavaScript
1
star
87

Die-Gedanken-sind-frei

Hier nutze ich Git/GitHub als eine art Blog. Dies ist kein Software Repo! Alle Artikel sind, wie der Titel vermuten lässt, unter einer freien Lizenz, erhältlich (cc-by-sa)! Most of the content is in german, but sometimes in english!
1
star