utils

package module
v0.0.0-...-cf3c62f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2016 License: GPL-3.0 Imports: 0 Imported by: 0

README

utils - A set of tools that I use in every project

Build Status GitHub license

My Utils for GoLang

Installing

go get github.com/legion-zver/utils

UnixTime

Support in ORM such as GORM (use int(11) by time) and marshaller to JSON to int64

Example JSON

import (
    "fmt"
    "encoding/json"
    "github.com/legion-zver/utils/unixtime"
)

type Struct struct {
    Created unixtime.Time `json:"created"`
}

func main() {
    b, err := json.Marshal(&Struct{Created: unixtime.Now()})
    if err != nil {
        fmt.Println(err)
        return
    }
    fmt.Println(string(b))
}

Result:

{"created":1471270764}
Benchmark Marshal JSON

On MacBook Pro 15 (i7, 8Gb):

Use unixtime.Time by 1000000 items:	 498.90682ms
Use time.Time by 1000000 items:		 1.556858113s

Using unixtime.Time increase marshal speed 3x

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL