Package field provides tools for working with fields (i.e., something with a name and value pair), for the Go programming language.
Find a file
2026-04-13 20:06:01 -07:00
impl field.GoStringer() 2026-04-13 19:53:09 -07:00
any.go docs 2026-04-04 21:31:56 -07:00
bool.go docs 2026-04-04 21:32:31 -07:00
bytes.go docs 2026-04-04 22:15:40 -07:00
complex.go docs 2026-04-04 22:10:50 -07:00
doc.go docs 2026-04-04 21:28:48 -07:00
error.go docs 2026-04-04 22:14:13 -07:00
field.go docs 2026-04-04 22:11:26 -07:00
fieldany.go docs 2026-04-04 22:14:45 -07:00
fields.go docss 2026-04-04 22:18:14 -07:00
float.go docs 2026-04-04 22:10:22 -07:00
go.mod stringly 2025-12-05 21:42:29 -08:00
go.sum stringly 2025-12-05 21:42:29 -08:00
int.go docs 2026-04-04 21:43:52 -07:00
LICENSE initial commits 2025-11-10 05:14:28 -08:00
ord.go ordinals 2026-04-04 20:53:49 -07:00
README.md docs 2026-04-04 21:07:07 -07:00
string.go field.FormattedString() 2026-04-13 20:06:01 -07:00
stringlyfield.go docs 2026-04-04 22:02:07 -07:00
test.go tests 2026-04-04 21:19:18 -07:00
time.go docs 2026-04-04 21:33:14 -07:00
uint.go docs 2026-04-04 21:43:05 -07:00
values.go docs 2026-04-04 22:18:53 -07:00

go-field

Package field provides tools for working with fields (i.e., something with a name and value pair), for the Go programming-language (golang).

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/codeberg.org/reiver/go-field

GoDoc

Examples

Here are some examples of fields being created.

import "codeberg.org/reiver/go-field"

// field.Field[string]
field1 := field.String("fruit", "cherry")

// field.Field[string]
field2 := field.Stringer("ip-address", ipv4)

// field.Field[error]
field3 := field.Error("error", err)

// field.Field[string]
field4 := field.Ord("index", 4)

// field.Field[int]
field5 := field.Ord("size", len(a))

// field.Field[time.Duration]
field6 := field.Duration("delta", 5 * time.Minute)

// field.Field[time.Bool]
field7 := field.Bool("exist", true)

// field.Field[time.Time]
field8 := field.Time("when-created", time.Now())

Here is how one can get the name and value of a field:

name := field8.FieldName()

value := field8.FieldValue()

You can also always get a string version of the value of a field with:

valueString := field8.FieldValueString()

Here is how to turn any type of field into a field.Field[any]:

var fa field.Field[any] = field.FieldAny(field1)

Import

To import package field use import code like the following:

import "codeberg.org/reiver/go-field"

Installation

To install package field do the following:

GOPROXY=direct go get codeberg.org/reiver/go-field

Author

Package field was written by Charles Iliya Krempeaux