go-cty

module
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: MIT

README

cty

cty (pronounced "see-tie") is a dynamic type system for applications written in Go that need to represent user-supplied values without losing type information. The primary intended use is for implementing configuration languages, but other uses may be possible too.

One could think of cty as being the reflection API for a language that doesn't exist, or that doesn't exist yet. It provides a set of value types and an API for working with values of that type.

Fundamentally what cty provides is equivalent to an interface{} with some dynamic type information attached, but cty encapsulates this to ensure that invariants are preserved and to provide a more convenient API.

As well as primitive types, basic collection types (lists, maps and sets) and structural types (object, tuple), the cty type and value system has some additional, optional features that may be useful to certain applications:

  • Representation of "unknown" values, which serve as a typed placeholder for a value that has yet to be determined. This can be a useful building-block for a type checker. Unknown values support all of the same operations as known values of their type, but the result will often itself be unknown.

  • Representation of values whose types aren't even known yet. This can represent, for example, the result of a JSON-decoding function before the JSON data is known.

Along with the type system itself, a number of utility packages are provided that build on the basics to help integrate cty into calling applications. For example, cty values can be automatically converted to other types, converted to and from native Go data structures, or serialized as JSON.

For more details, see the following documentation:


License

Copyright 2017 Martin Atkins

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Directories

Path Synopsis
cty
Package cty (pronounced see-tie) provides some infrastructure for a type system that might be useful for applications that need to represent configuration values provided by the user whose types are not known at compile time, particularly if the calling application also allows such values to be used in expressions.
Package cty (pronounced see-tie) provides some infrastructure for a type system that might be useful for applications that need to represent configuration values provided by the user whose types are not known at compile time, particularly if the calling application also allows such values to be used in expressions.
convert
Package convert contains some routines for converting between cty types.
Package convert contains some routines for converting between cty types.
function
Package function builds on the functionality of cty by modeling functions that operate on cty Values.
Package function builds on the functionality of cty by modeling functions that operate on cty Values.
function/stdlib
Package stdlib is a collection of cty functions that are expected to be generally useful, and are thus factored out into this shared library in the hope that cty-using applications will have consistent behavior when using these functions.
Package stdlib is a collection of cty functions that are expected to be generally useful, and are thus factored out into this shared library in the hope that cty-using applications will have consistent behavior when using these functions.
gocty
Package gocty deals with converting between cty Values and native go values.
Package gocty deals with converting between cty Values and native go values.
json
Package json provides functions for serializing cty types and values in JSON format, and for decoding them again.
Package json provides functions for serializing cty types and values in JSON format, and for decoding them again.
msgpack
Package msgpack provides functions for serializing cty values in the msgpack encoding, and decoding them again.
Package msgpack provides functions for serializing cty values in the msgpack encoding, and decoding them again.
set

Jump to

Keyboard shortcuts

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