Skip to content
Serialize any custom type or convert any content to []byte or string, for Go Programming Language
Branch: master
Clone or download
Latest commit b61f2e8 Feb 17, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
json
jsonp
markdown
vendor/github.com
xml Push my work so far Sep 2, 2016
.gitignore
.travis.yml
LICENSE
README.md
logo.jpg update readme fix text default serializer Sep 10, 2016
serializer.go
serializer_test.go

README.md


Build Status

Awesome GoLang

Report A+

License

Releases

Godoc

Chat



Serialize any custom type to []byte or string. Your custom serializers are, finally, organised.

Easy-to-use

While providing robust set of features, simple to understand.

Built'n supported serializers:

Go here to learn how you can create and use your own custom Serializer.

This package is already used by Iris web framework and Q web framework, examples here.

Installation

The only requirement is the Go Programming Language, at least v1.6.

$ go get -u github.com/kataras/go-serializer

Usage

package main

import (
  "github.com/kataras/go-serializer"
  "github.com/kataras/go-serializer/markdown"
)

func main() {
  markdownSerializer := markdown.New()

  serializer.For("markdown", markdownSerializer)

  result, err := serializer.SerializeToString("markdown", "## Hello")
  // Optional third parameter is a map[string]interface{}, which is any runtime options for the serializers registered to 'markdown' key

  println(result)
}

explanation

Create your own serializer or use one of the project's built'n serializers, in this case we will use the markdown serializer will receive markdown content as string and return the HTML form of them

markdownSerializer := markdown.New()

Learn how to create your own custom serializer go to the serializer_test.go, it's just one function.

mySerializers := serializer.Serializers{}
mySerializers.For("key", markdownSerializer)

Add the serializer to a custom key, using the default Serializers{}. It supports more than one serializer for each key

serializer.For("markdown", markdownSerializer)

Serialize something with the registered serializers by a key. If more than one Serializer is registered to the same key then the final result will be the results of all of its(key's) serializers

result, err := serializer.SerializeToString("markdown", "## Hello")

.Serialize(...) returns []byte, SerializeToString(...) returns string, they're the same use that you need

Print the result, will be just a <h2>Hello</h2>

println(result)

For more, please read each of the Serializers you want to use, built'n supported are:

You can also navigate to the godocs.

FAQ

If you'd like to discuss this package, or ask questions about it, feel free to

Versioning

Current: v0.0.5

Read more about Semantic Versioning 2.0.0

People

The author of go-serializer is @kataras.

Contributing

If you are interested in contributing to the go-serializer project and add more serializers, please make a PR.

License

This project is licensed under the MIT License.

License can be found here.

You can’t perform that action at this time.