Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.
/ gob64 Public archive

Marshall/Unmarshall Gob Base64 Encoded String To Struct

License

Notifications You must be signed in to change notification settings

moizmali/gob64

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gob64

Marshal/Unmarshal Base64 Encoded Gob To String.

Usage

Marshal a struct:

package main

import (
	"fmt"

	"github.com/moizalicious/gob64"
)

type data struct {
	Foo string
	Bar string
}

func main() {
	d := data{
		Foo: "ABC",
		Bar: "XYZ",
	}

	s, err := gob64.Marshal(d)
	if err != nil {
		panic(err)
	}

	fmt.Println(s)
}

The above will print the following to the console:

Iv+BAwEBBGRhdGEB/4IAAQIBA0ZvbwEMAAEDQmFyAQwAAAAN/4IBA0FCQwEDWFlaAA==

Unmarshal an encoded string:

package main

import (
	"fmt"

	"github.com/moizalicious/gob64"
)

type data struct {
	Foo string
	Bar string
}

func main() {
	s := "Iv+BAwEBBGRhdGEB/4IAAQIBA0ZvbwEMAAEDQmFyAQwAAAAN/4IBA0FCQwEDWFlaAA=="

	var d data
	if err := gob64.Unmarshal(s, &d); err != nil {
		panic(err)
	}

	fmt.Println(d)
}

The above will print the following to the console:

{ABC XYZ}

About

Marshall/Unmarshall Gob Base64 Encoded String To Struct

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages