hashicorp-copywrite[bot]
5fb9df1640
* Adding explicit MPL license for sub-package This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at <Blog URL>, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> |
1 year ago | |
---|---|---|
.. | ||
README.md | Revert "Move `structs.CheckID` to a new top-level package, `types`." | 9 years ago |
area.go | [COMPLIANCE] License changes (#18443) | 1 year ago |
checks.go | [COMPLIANCE] License changes (#18443) | 1 year ago |
node_id.go | [COMPLIANCE] License changes (#18443) | 1 year ago |
tls.go | [COMPLIANCE] License changes (#18443) | 1 year ago |
tls_test.go | [COMPLIANCE] License changes (#18443) | 1 year ago |
README.md
Consul types
Package
The Go language has a strong type system built into the language. The
types
package corrals named types into a single package that is terminal in
go
's import graph. The types
package should not have any downstream
dependencies. Each subsystem that defines its own set of types exists in its
own file, but all types are defined in the same package.
Why
Everything should be made as simple as possible, but not simpler.
string
is a useful container and underlying type for identifiers, however
the string
type is effectively opaque to the compiler in terms of how a
given string is intended to be used. For instance, there is nothing
preventing the following from happening:
// `map` of Widgets, looked up by ID
var widgetLookup map[string]*Widget
// ...
var widgetID string = "widgetID"
w, found := widgetLookup[widgetID]
// Bad!
var widgetName string = "name of widget"
w, found := widgetLookup[widgetName]
but this class of problem is entirely preventable:
type WidgetID string
var widgetLookup map[WidgetID]*Widget
var widgetName
TL;DR: intentions and idioms aren't statically checked by compilers. The
types
package uses Go's strong type system to prevent this class of bug.