MCPcopy Create free account

hub / github.com/mmcgrana/gobyexample / types & classes

Types & classes25 in github.com/mmcgrana/gobyexample

StructContainer
Container holds a map of counters; since we want to update it concurrently from multiple goroutines, we add a `Mutex` to synchronize access. Note that
examples/mutexes/mutexes.go:19
StructExample
Example is info extracted from an example file
tools/generate.go:109
StructList
Let's look at the `List` type from the [previous example](generics) again. In that example we had an `AllElements` method that returned a slice of all
examples/range-over-iterators/range-over-iterators.go:19
StructList
As an example of a generic type, `List` is a singly-linked list with values of any type.
examples/generics/generics.go:28
StructNesting
The `parent>child>plant` field tag tells the encoder to nest all `plant`s under `<parent><child>...`
examples/xml/xml.go:59
StructPerson
We can use the same technique to sort a slice of values that aren't built-in types.
examples/sorting-by-functions/sorting-by-functions.go:31
StructPlant
Plant will be mapped to XML. Similarly to the JSON examples, field tags contain directives for the encoder and decoder. Here we use some special featu
examples/xml/xml.go:18
StructSeg
Seg is a segment of an example
tools/generate.go:102
TypeAliasServerState
Our enum type `ServerState` has an underlying `int` type.
examples/enums/enums.go:13
StructargError
A custom error type usually has the suffix "Error".
examples/custom-errors/custom-errors.go:14
Structbase
examples/struct-embedding/struct-embedding.go:11
Structcircle
examples/interfaces/interfaces.go:22
Structcontainer
A `container` _embeds_ a `base`. An embedding looks like a field without a name.
examples/struct-embedding/struct-embedding.go:21
Interfacedescriber
examples/struct-embedding/struct-embedding.go:52
Structelement
examples/range-over-iterators/range-over-iterators.go:23
Structelement
examples/generics/generics.go:32
Interfacegeometry
Here's a basic interface for geometric shapes.
examples/interfaces/interfaces.go:12
Structperson
This `person` struct type has `name` and `age` fields.
examples/structs/structs.go:10
Structpoint
examples/string-formatting/string-formatting.go:12
StructreadOp
In this example our state will be owned by a single goroutine. This will guarantee that the data is never corrupted with concurrent access. In order t
examples/stateful-goroutines/stateful-goroutines.go:27
Structrect
examples/methods/methods.go:7
Structrect
For our example we'll implement this interface on `rect` and `circle` types.
examples/interfaces/interfaces.go:19
Structresponse1
We'll use these two structs to demonstrate encoding and decoding of custom types below.
examples/json/json.go:16
Structresponse2
Only exported fields will be encoded/decoded in JSON. Fields must start with capital letters to be exported.
examples/json/json.go:23
StructwriteOp
examples/stateful-goroutines/stateful-goroutines.go:31