Gami13 / WSV-golang

Simple WSV (Whitspace Separated Values) parser for Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WSV-golang

This package is a simple implementation of a parser for White Space Separated Values (WSV) in Go as described in the WSV Guide.

Installation

go get github.com/gami13/wsv-golang

Usage

Parsing

package main

import (
	"github.com/gami13/wsv-golang"
)

func main() {
	result, err := wsv.ParseDocument("a b c\n1 2 3")
	if err != nil {
		//handle error
	}
}

In this example result is a [][]string with the following content:

[["a" "b" "c"] ["1" "2" "3"]]

you can also use this to read from a file:

file, err := os.ReadFile("test_input.wsv")
if err != nil {
	//handle error
}
result, err := wsv.ParseDocument(string(file))
if err != nil {
	//handle error
}

Serialization

package main

import (
	"github.com/gami13/wsv-golang"
)

func main() {
	//SERIALIZE DOCUMENT
	result := wsv.Serialize(input)

	//SERIALIZE ROW
	result := wsv.SerializeRow(input)
}

In this example result is a string , in the case of Serialize, the input is of type [][]string and in the case of SerializeRow the input is of type []string.

Future plans

  • Add serialization

About

Simple WSV (Whitspace Separated Values) parser for Go

License:MIT License


Languages

Language:Go 100.0%