![Releases](https://camo.githubusercontent.com/8341aa5dfaa4ec470e24c80c1376aa24f77b79ae2a97fa4de50dd2eee427df10/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f7368616d61746f6e2f7a65726f666f726d61747465722e737667)
golang version zeroformatter
go get github.com/shamaton/zeroformatter
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)
}
}
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)
}
}
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 |
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) |
C# |
Go |
T[], List |
[]T, [N]T |
C# |
Go |
Dictionary<K, V> |
map[K]V |
type?
is not supported, because golang doen't allow null in primitve types.
This library is under the MIT License.