go-netfield provides tools for parsing "net fields", for the Go programming language — i.e., the type of fields found in HTTP headers & trailers, as well as SMTP headers.
Net-Fields look like this:
Content-Type: text/plain
Subject: Hello world!
Something: once
twice
thrice
fource
Fruits: apple banana cherry
Note that each line is terminated with a "\r\n"
.
Also note that multi-line net-fields are possible. To create a multi-line Net-Field, the beginning of the continuing field-body line must start with any type of linear-spacing.
Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-netfield
import "github.com/reiver/go-netfield"
// ...
fieldName, fieldBody, err := netfield.Parse(runescanner)
In IETF RFC822, the linear-spacing characters are defined by the definition for "LWSP-char":
LWSP-char = SPACE / HTAB
This package expands the definition of "LWSP-char" to embrace Unicode. And includes a number of other character.
U+0009
— horizontal tab (␉)U+0020
— space (␠)U+1680
— ogham space markU+180E
— mongolian vowel separatorU+2000
— en quadU+2001
— em quadU+2002
— en spaceU+2003
— em spaceU+2004
— three-per-em spaceU+2005
— four-per-em spaceU+2006
— six-per-em spaceU+2007
— figure spaceU+2008
— punctuation spaceU+2009
— thin spaceU+200A
— hair spaceU+205F
— medium mathematical spaceU+3000
— ideographic space