golibs
general purpose Golang code (to be included in other projects)
Science Score: 54.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
✓Academic publication links
Links to: zenodo.org -
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.8%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
general purpose Golang code (to be included in other projects)
Basic Info
- Host: GitHub
- Owner: SimonWaldherr
- License: mit
- Language: Go
- Default Branch: master
- Homepage: https://simonwaldherr.github.io/golibs/
- Size: 2.36 MB
Statistics
- Stars: 121
- Watchers: 7
- Forks: 16
- Open Issues: 2
- Releases: 4
Topics
Metadata Files
README.md
golibs
golang functions (to be included in other projects)
sh
go get -u -t simonwaldherr.de/go/golibs/...
coverage & tests
sh
go test ./...
. | service | info
---|---------|------
| github.com | test via GitHub Workflow
| goreportcard.com | report card
| | go tool cover
| fossa.io | license report
| | free + open source license
| godoc.org | documentation
| godoc @ github.io | documentation
| zenodo.org | Digital Object Identifier
each new build gets tested in multiple steps:
- on development i regularly type
go testfrom 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
- semver is a semantic version parsing/checking package
- ssl generates ssl certificates for https
- stack can store your values in stacks and rings
- structs use structs like maps
- table prints structs like ASCII or Markdown tables
- 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 - 
go
import "simonwaldherr.de/go/golibs/ansi"
ansi can print colored and styled text to your terminal:
- green, yellow and red strings:
go
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:
go
fmt.Printf("this is %v and %v text", ansi.Bold("bold"), ansi.Underline("underlined"))
arg - 
go
import "simonwaldherr.de/go/golibs/arg"
the arg package simplifies cli flags (arguments)
as - 
go
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:
go
var x string = as.String(int(32))
- string to int:
go
var x int = as.Int("32")
- string to time:
go
var x time.Time = as.Time("31.12.2014")
bitmask - 
go
import "simonwaldherr.de/go/golibs/bitmask"
with bitmask you can set and get bits to and from a bitmask:
go
i := bitmask.New(0b11111111)
i.Set(0, false)
cache - 
go
import "simonwaldherr.de/go/golibs/cache"
cachedfile - 
go
import "simonwaldherr.de/go/golibs/cachedfile"
cachedfile simplifies reading and writing from and to disk and adds caching
do
go
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
go
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 - 
go
import "simonwaldherr.de/go/golibs/channel"
channel simplifies channel operations, e.g. sending the same data to multiple receivers
```go 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 - 
go
import "simonwaldherr.de/go/golibs/csv"
file - 
go
import "simonwaldherr.de/go/golibs/file"
file wraps around the standard functions to simplify reading and writing on disk
go
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):
go
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 - 
go
import "simonwaldherr.de/go/golibs/foreach"
foreach calls a given function for each element of a [ JSON-string ]
gcurses - 
go
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.
```go 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 - 
go
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:
```go 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 - 
go
import "simonwaldherr.de/go/golibs/graphics"
with graphics you can manipulate images
go
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:
```go 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 - 
go
import "simonwaldherr.de/go/golibs/http"
log - 
go
import "simonwaldherr.de/go/golibs/log"
re - 
go
import "simonwaldherr.de/go/golibs/re"
re helps you whenever you have to do something multiple times
go
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 - 
go
import "simonwaldherr.de/go/golibs/regex"
regex is a layer to speed up your regular expression development
go
str, err := regex.ReplaceAllString("Ipsum Lorem", "([^ ]+) ([^ ]+)", "$2 $1")
rss - 
go
import "simonwaldherr.de/go/golibs/rss"
rss is a rss feed parser based on Golangs std xml package
go
podcast, err := rss.Read(url)
if err == nil {
for _, episode := range podcast.Items {
fmt.Println(episode.Title)
}
}
ssl - 
go
import "simonwaldherr.de/go/golibs/ssl"
ssl generates ssl certificates for https
go
err := ssl.Generate(options)
stack - 
go
import "simonwaldherr.de/go/golibs/stack"
with stack you can store your values in stacks and rings
go
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 - 
go
import "simonwaldherr.de/go/golibs/structs"
xmath - 
go
import "simonwaldherr.de/go/golibs/xmath"
xmath provides a few mathematical functions like Max, Min, Sum, Median, Harmonic-mean, ...
```go 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 - 
go
import "simonwaldherr.de/go/golibs/xtime"
xtime implements a subset of strftime
go
t, _ := time.Now()
fmt.Println(xtime.Fmt("%Y-%m-%d %H:%M:%S", t))
Owner
- Name: Simon Waldherr
- Login: SimonWaldherr
- Kind: user
- Location: Bavaria, Germany
- Company: RUBIX GmbH
- Website: https://simonwaldherr.de/
- Twitter: SimonWaldherr
- Repositories: 294
- Profile: https://github.com/SimonWaldherr
curr. #DataAnalyst, orig. #MechatronicsEngineer, hobby #Programmer #ComputerScience, deputy #FireBrigade commander, hobby #Photographer, loving #OpenSource
Citation (CITATION.cff)
cff-version: 1.2.0 message: "If you refer to this project, please cite it as below." authors: - family-names: "Waldherr" given-names: "Simon" title: "golibs" version: 0.13.0 doi: 10.5281/zenodo.7015104 date-released: 2022-08-22 url: "https://github.com/SimonWaldherr/golibs"
GitHub Events
Total
- Watch event: 1
Last Year
- Watch event: 1
Committers
Last synced: about 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| Simon Waldherr | g****t@s****u | 236 |
| fossabot | b****s@f****o | 1 |
| The Codacy Badger | b****r@c****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 3
- Total pull requests: 4
- Average time to close issues: 6 days
- Average time to close pull requests: about 2 hours
- Total issue authors: 2
- Total pull request authors: 4
- Average comments per issue: 0.0
- Average comments per pull request: 1.0
- Merged pull requests: 2
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- CodeLingoTeam (1)
- dominikschulz (1)
Pull Request Authors
- SimonWaldherr (1)
- CodeLingoBot (1)
- fossabot (1)
- codacy-badger (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
- Total downloads: unknown
-
Total dependent packages: 6
(may contain duplicates) -
Total dependent repositories: 1
(may contain duplicates) - Total versions: 28
proxy.golang.org: github.com/simonwaldherr/golibs
- Homepage: https://github.com/simonwaldherr/golibs
- Documentation: https://pkg.go.dev/github.com/simonwaldherr/golibs#section-documentation
- License: MIT
-
Latest release: v0.18.0
published over 1 year ago
Rankings
proxy.golang.org: github.com/SimonWaldherr/golibs
- Homepage: https://github.com/SimonWaldherr/golibs
- Documentation: https://pkg.go.dev/github.com/SimonWaldherr/golibs#section-documentation
- License: MIT
-
Latest release: v0.18.0
published over 1 year ago
Rankings
Dependencies
- github.com/mattn/goveralls v0.0.11
- github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5
- github.com/rs/dnscache v0.0.0-20211102005908-e0241e321417
- github.com/sozorogami/gover v0.0.0-20171022184752-b58185e213c5
- github.com/yuin/goldmark v1.4.13
- golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8
- golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4
- golang.org/x/net v0.0.0-20220812174116-3211cb980234
- golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
- golang.org/x/sys v0.0.0-20220818161305-2296e01440c6
- golang.org/x/tools v0.1.12
- github.com/mattn/goveralls v0.0.11
- github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5
- github.com/rs/dnscache v0.0.0-20211102005908-e0241e321417
- github.com/sozorogami/gover v0.0.0-20171022184752-b58185e213c5
- github.com/yuin/goldmark v1.4.13
- golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8
- golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4
- golang.org/x/net v0.0.0-20220812174116-3211cb980234
- golang.org/x/sync v0.0.0-20190423024810-112230192c58
- golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
- golang.org/x/sys v0.0.0-20220818161305-2296e01440c6
- golang.org/x/tools v0.1.12