wsv

package module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2024 License: MIT Imports: 2 Imported by: 0

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseAsArray

func ParseAsArray(content string) ([]string, error)

Parses a WSV document's line as an array of strings.

func ParseAsJaggedArray

func ParseAsJaggedArray(content string) ([][]string, error)

Parses a WSV document as a jagged array of strings.

func ParseDocument

func ParseDocument(content string) ([][]string, error)

func ParseLineAsArray

func ParseLineAsArray(content string) ([]string, error)

func Serialize added in v0.0.3

func Serialize(values [][]string) string

func SerializeRow added in v0.0.3

func SerializeRow(values []string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL