Giter Site home page Giter Site logo

zeroformatter's Introduction

zeroformatter

GoDoc Build Status Coverage Status Releases

golang version zeroformatter

Usage

Installation

go get github.com/shamaton/zeroformatter

How to use

use simply

package main;

import (
  "github.com/shamaton/zeroformatter"
  "log"
)

func main() {
	type Struct struct {
		String string
	}
	h := Struct{String: "zeroformatter"}

	d, err := zeroformatter.Serialize(h)
	if err != nil {
		log.Fatal(err)
	}
	r := Struct{}
	err = zeroformatter.Deserialize(&r, d)
	if err != nil {
		log.Fatal(err)
	}
}

delay

package main;

import (
  "github.com/shamaton/zeroformatter"
  "log"
)

func how_to_use(b []byte) {
	type Struct struct {
		String string
	}
	
	r := Struct{}
	dds, _ := zeroformatter.DelayDeserialize(&r, b)
	
	// by element
	if err := dds.DeserializeByElement(&r.String); err != nil {
		log.Fatal(err)
	}
	
	// or by index
	if err := dds.DeserializeByIndex(0); err != nil {
	  log.Fatal(err)
	}
}

Supported type

Primitive

C# Go
Int16 int16
Int32 int32, int
Int64 int64
UInt16 uint16
UInt32 uint32, uint
UInt64 uint64
Single float32
Double float64
Boolean bool
Byte uint8
SByte int8
TimeSpan time.Duration
DateTime time.Time
String string

Extension within golang

As these types can not convert with primitive type, I defined parent classes in golang. These are only wrapping. please see codes.

C# Go
Char zeroformatter.Char(rune)
DateTimeOffset zeroformatter.DateTimeOffset(time.Time)

Array/Slice

C# Go
T[], List []T, [N]T

Map

C# Go
Dictionary<K, V> map[K]V

Object

C# Go
Struct struct

Not supported

type? is not supported, because golang doen't allow null in primitve types.

License

This library is under the MIT License.

zeroformatter's People

Contributors

shamaton avatar

Stargazers

Pouya Vedadiyan avatar xiaoxia_yu avatar Enrico Speranza avatar choirudin avatar  avatar pedoc avatar Camilo E. Hidalgo Estevez avatar  avatar Kiswono Prayogo avatar andrea denisse avatar Kent Gruber avatar kyokomi avatar sasanuki avatar Hideo Hattori avatar ichikawa_yuta avatar Madein云中子 avatar myoshika avatar Chunghoon Im avatar Max avatar ChiuanWei avatar Aleksandr Glyzov avatar Roman Heinrich avatar Joonho Choi avatar Pedro Rodriguez avatar Fabio Ribeiro avatar Serge Simard avatar redaready avatar Yun Zhi Lin avatar pocketberserker avatar Potter Dai avatar

Watchers

 avatar Chunghoon Im avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.