Skip to content

Commit

Permalink
add Go Report Card badge to readme
Browse files Browse the repository at this point in the history
gometalinter changes
  • Loading branch information
SimonWaldherr committed Nov 29, 2015
1 parent b951932 commit cf2989a
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 245 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# Folders
_obj
_test
.vscode
-trash

# Architecture specific extensions/prefixes
*.[568vq]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ go test ./...
![Windows Build Status](https://simonwaldherr.de/icon/win.png) | [![Build status](https://img.shields.io/appveyor/ci/SimonWaldherr/golibs.svg?style=flat-square)](https://ci.appveyor.com/project/SimonWaldherr/golibs/branch/master) | appveyor.com | test under windows
![Linux Build Status](https://simonwaldherr.de/icon/tux.png) | [![Build status](https://magnum-ci.com/status/e9ccc5689f4135e4021475bfdf0cf527.png)](https://magnum-ci.com/public/c4dba43a1c41dbff557e/builds) | magnum-ci.com | just another ci service
![Linux Build Status](https://simonwaldherr.de/icon/tux1.png) | [![Build Status](https://semaphoreci.com/api/v1/projects/fe1a7a53-a2c0-4bc0-a539-4af4ef13d49f/487313/shields_badge.svg)](https://semaphoreci.com/simonwaldherr/golibs) | semaphoreci.com | yet another ci service
| [![Go Report Card](http://goreportcard.com/badge/simonwaldherr/golibs)](http://goreportcard.com/report/simonwaldherr/golibs) | goreportcard.com | report card
| [![Coverage Status](https://img.shields.io/coveralls/SimonWaldherr/golibs.svg?style=flat-square)](https://coveralls.io/r/SimonWaldherr/golibs) | coveralls.io | test coverage
| [![codecov.io](http://codecov.io/github/SimonWaldherr/golibs/coverage.svg?branch=master)](http://codecov.io/github/SimonWaldherr/golibs?branch=master) | codecov.io | test coverage
| [![Coverage Status](https://img.shields.io/coveralls/SimonWaldherr/golibs.svg?style=flat-square)](https://simonwaldherr.de/gocover/golibs/) | | go tool cover
Expand Down
9 changes: 7 additions & 2 deletions ansi/ansi.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// with this package you can print colored and styled text to your terminal.
// Package ansi can print colored and styled text to your terminal.
package ansi

import (
"fmt"
"log"
)

// Col defines supported colors
type Col int

// defines supported colors
Expand All @@ -19,6 +20,8 @@ const (
Cyan
White
)

// defines text styling options
const (
TReset = Col(iota)
TBold
Expand Down Expand Up @@ -56,6 +59,7 @@ const (
BgWhite
)

// Set sets styling options on strings and stringable interfaces
func Set(str interface{}, Attribute ...Col) string {
var rstr = fmt.Sprint(str)
for _, attr := range Attribute {
Expand All @@ -69,7 +73,7 @@ func Color(str interface{}, col Col) string {
return fmt.Sprintf("\033[3%vm%v\033[0m", col, str)
}

// Color adds the color code of col as background color to str and returns as string
// BgColor adds the color code of col as background color to str and returns as string
func BgColor(str interface{}, col Col) string {
return fmt.Sprintf("\033[4%vm%v\033[0m", col, str)
}
Expand All @@ -84,6 +88,7 @@ func Underline(str interface{}) string {
return fmt.Sprintf("\033[4m%v\033[0m", str)
}

// Log prints red text via log package
func Log(valuea ...interface{}) interface{} {
if valuea[1] != nil {
log.Println(Color(valuea[1], Red))
Expand Down
3 changes: 2 additions & 1 deletion as/as.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// The "as" package helps by converting various data types to various other types
// Package as helps by converting various data types to various other types
package as

import (
Expand Down Expand Up @@ -469,6 +469,7 @@ func DBType(str string) string {
}
}

// DBTypeMultiple returns the lowest common denominator of a type for all inserted DBTypes
func DBTypeMultiple(val []string) string {
var typeint int
for _, typ := range val {
Expand Down
38 changes: 19 additions & 19 deletions as/as_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func Test_Uint(t *testing.T) {
}
}

func println_type(t *testing.T, str, type1, type2 string) {
func printlnType(t *testing.T, str, type1, type2 string) {
t1, err := Type(str)

if err != nil {
Expand All @@ -323,24 +323,24 @@ func println_type(t *testing.T, str, type1, type2 string) {
}

func Test_Type(t *testing.T) {
println_type(t, "true", "bool", "bool")
println_type(t, "1000", "int", "int")
println_type(t, "2^16", "int", "int")
println_type(t, "10E24", "int", "int")
println_type(t, "10 EUR", "price", "string")
println_type(t, "10.23 £", "price", "string")
println_type(t, "01.01.1970", "date", "string")
println_type(t, "06.06.1989", "date", "string")
println_type(t, "2015-05-04T13:37:42", "date", "string")
println_type(t, "[email protected]", "email", "string")
println_type(t, "978-3499626005", "isbn", "string")
println_type(t, "127.0.0.1", "ipv4", "string")
println_type(t, "2a01:4f8:192:34aa::10", "ipv6", "string")
println_type(t, "b8:c7:5d:c6:6c:c6", "mac", "string")
println_type(t, "#fefefe", "color", "string")
println_type(t, "THk4Z1JFSlVlWEJsSUhKbGRIVnlibk1nWVNCRVlYUmhZbUZ6WlNCVWVYQmxJRzltSUdFZ2MzUnlhVzVuTGcwS1puVnVZeUJFUWxSNWNHVW9jM1J5SUhOMGNtbHVaeWtnYzNSeWFXNW5JSHNOQ2dsMExDQmxjbklnT2owZ1ZIbHdaU2h6ZEhJcERRb0phV1lnWlhKeUlDRTlJRzVwYkNCN0RRb0pDWEpsZEhWeWJpQWljM1J5YVc1bklnMEtDWDBOQ2dsemQybDBZMmdnZENCN0RRb0pZMkZ6WlNBaVltOXZiQ0lzSUNKcGJuUWlMQ0FpYzNSeWFXNW5JaXdnSW1ac2IyRjBJam9OQ2drSmNtVjBkWEp1SUhRTkNnbGtaV1poZFd4ME9nMEtDUWx5WlhSMWNtNGdJbk4wY21sdVp5SU5DZ2w5RFFwOQ==", "base64", "string")
println_type(t, "!\"#$%&'()*+,-./0123456789:;<=>?@[\\]^_`{|}~ ", "string", "string")
println_type(t, "😃", "", "string")
printlnType(t, "true", "bool", "bool")
printlnType(t, "1000", "int", "int")
printlnType(t, "2^16", "int", "int")
printlnType(t, "10E24", "int", "int")
printlnType(t, "10 EUR", "price", "string")
printlnType(t, "10.23 £", "price", "string")
printlnType(t, "01.01.1970", "date", "string")
printlnType(t, "06.06.1989", "date", "string")
printlnType(t, "2015-05-04T13:37:42", "date", "string")
printlnType(t, "[email protected]", "email", "string")
printlnType(t, "978-3499626005", "isbn", "string")
printlnType(t, "127.0.0.1", "ipv4", "string")
printlnType(t, "2a01:4f8:192:34aa::10", "ipv6", "string")
printlnType(t, "b8:c7:5d:c6:6c:c6", "mac", "string")
printlnType(t, "#fefefe", "color", "string")
printlnType(t, "THk4Z1JFSlVlWEJsSUhKbGRIVnlibk1nWVNCRVlYUmhZbUZ6WlNCVWVYQmxJRzltSUdFZ2MzUnlhVzVuTGcwS1puVnVZeUJFUWxSNWNHVW9jM1J5SUhOMGNtbHVaeWtnYzNSeWFXNW5JSHNOQ2dsMExDQmxjbklnT2owZ1ZIbHdaU2h6ZEhJcERRb0phV1lnWlhKeUlDRTlJRzVwYkNCN0RRb0pDWEpsZEhWeWJpQWljM1J5YVc1bklnMEtDWDBOQ2dsemQybDBZMmdnZENCN0RRb0pZMkZ6WlNBaVltOXZiQ0lzSUNKcGJuUWlMQ0FpYzNSeWFXNW5JaXdnSW1ac2IyRjBJam9OQ2drSmNtVjBkWEp1SUhRTkNnbGtaV1poZFd4ME9nMEtDUWx5WlhSMWNtNGdJbk4wY21sdVp5SU5DZ2w5RFFwOQ==", "base64", "string")
printlnType(t, "!\"#$%&'()*+,-./0123456789:;<=>?@[\\]^_`{|}~ ", "string", "string")
printlnType(t, "😃", "", "string")
}

func Test_TypeMultiple(t *testing.T) {
Expand Down
10 changes: 9 additions & 1 deletion cache/cache.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// simple caching with GC
// Package cache simplifies caching with GC
package cache

import (
Expand All @@ -10,6 +10,7 @@ import (
"time"
)

// Item as a single object with an interface as value and two time.Time values for creation and expiration dates
type Item struct {
Object interface{}
Creation time.Time
Expand All @@ -23,6 +24,7 @@ func (item *Item) isExpired() bool {
return item.Expiration.Before(time.Now())
}

// Cache is a storage for all Item items
type Cache struct {
Expiration time.Duration
items map[string]*Item
Expand All @@ -43,6 +45,7 @@ func (cache *Cache) String() string {
return str
}

// Set creates an Item in the cache, if there is already an item with that name it get overwritten
func (cache *Cache) Set(key string, value interface{}) {
cache.items[key] = &Item{
Object: value,
Expand All @@ -51,6 +54,7 @@ func (cache *Cache) Set(key string, value interface{}) {
}
}

// SetWithDuration does the same as Set but with an specific expiration date
func (cache *Cache) SetWithDuration(key string, value interface{}, creation time.Time, duration time.Duration) {
cache.items[key] = &Item{
Object: value,
Expand All @@ -59,10 +63,12 @@ func (cache *Cache) SetWithDuration(key string, value interface{}, creation time
}
}

// Time returns the creation date of a cached item
func (cache *Cache) Time(key string) time.Time {
return cache.items[key].Creation
}

// Get returns the value of a cached item or nil if expired
func (cache *Cache) Get(key string) interface{} {
item, ok := cache.items[key]
if !ok || item.isExpired() {
Expand All @@ -71,10 +77,12 @@ func (cache *Cache) Get(key string) interface{} {
return item.Object
}

// Delete deletes a cached item
func (cache *Cache) Delete(key string) {
delete(cache.items, key)
}

// Add creates an cached item
func (cache *Cache) Add(key string, value interface{}) bool {
item := cache.Get(key)
if item != nil {
Expand Down
97 changes: 0 additions & 97 deletions dump/dump.go

This file was deleted.

66 changes: 0 additions & 66 deletions dump/dump_test.go

This file was deleted.

Loading

0 comments on commit cf2989a

Please sign in to comment.