golang gob utils for common use
To get the package, execute:
go get github.com/gofika/gobutil
package main
import (
"fmt"
"github.com/gofika/gobutil"
)
func main() {
type Foo struct {
Name string
Value int
}
type Bar struct {
Name string
Value int
}
foo := &Foo{"Jason", 100}
// deep copy for different struct
bar, err := gobutil.DeepCopy[Bar](foo)
if err != nil {
fmt.Printf("DeepCopy failed. err: %s\n", err.Error())
return
}
fmt.Printf("bar.Name: %s\n", bar.Name)
fmt.Printf("bar.Value: %d\n", bar.Value)
}