go-cty
moduleThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
README¶
cty
cty (pronounced "see-tie", emoji: 👀 👔,IPA: /si'tʰaɪ/)is a dynamic type system for applications writtenin Go that need to represent user-supplied values without losing typeinformation. The primary intended use is for implementing configurationlanguages, but other uses may be possible too.
One could think ofcty as being the reflection API for a language thatdoesn't exist, or that doesn't existyet. It provides a set of value typesand an API for working with values of that type.
Fundamentally whatcty provides is equivalent to anany with somedynamic type information attached, butcty encapsulates this to ensure thatinvariants are preserved and to provide a more convenient API.
As well as primitive types, basic collection types (lists, maps and sets) andstructural types (object, tuple), thecty type and value system has someadditional, optional features that may be useful to certain applications:
Representation of "unknown" values, which serve as a typed placeholder fora value that has yet to be determined. This can be a useful building-blockfor a type checker. Unknown values support all of the same operations asknown values of their type, but the result will often itself be unknown.
Representation of values whosetypes aren't even known yet. This canrepresent, for example, the result of a JSON-decoding function before theJSON data is known.
Along with the type system itself, a number of utility packages are providedthat build on the basics to help integratecty 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:
- Concepts
- Full Description of the
ctyTypes - API Reference (godoc)
- Conversion between
ctytypes - Conversion to and from native Go values
- JSON serialization
ctyFunctions system- Compatibility Policy for future Minor Releases: pleasereview this before using
ctyin your application to avoid depending onimplementation details that may change.
License
Copyright 2017 Martin Atkins
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, 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 THESOFTWARE.
Directories¶
| Path | Synopsis |
|---|---|
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. |
ctymarks Package ctymarks contains some ancillary types, values, and constants for use with mark-related parts of the main cty package. | Package ctymarks contains some ancillary types, values, and constants for use with mark-related parts of the main cty package. |
ctystrings Package ctystrings is a collection of string manipulation utilities which intend to help application developers implement string-manipulation functionality in a way that respects the cty model of strings, even when they are working in the realm of Go strings. | Package ctystrings is a collection of string manipulation utilities which intend to help application developers implement string-manipulation functionality in a way that respects the cty model of strings, even when they are working in the realm of Go strings. |
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. |