Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/mmcgrana/gobyexample
/ types & classes
Types & classes
25 in github.com/mmcgrana/gobyexample
⨍
Functions
190
◇
Types & classes
25
Struct
Container
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
Struct
Example
Example is info extracted from an example file
tools/generate.go:109
Struct
List
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
Struct
List
As an example of a generic type, `List` is a singly-linked list with values of any type.
examples/generics/generics.go:28
Struct
Nesting
The `parent>child>plant` field tag tells the encoder to nest all `plant`s under `<parent><child>...`
examples/xml/xml.go:59
Struct
Person
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
Struct
Plant
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
Struct
Seg
Seg is a segment of an example
tools/generate.go:102
TypeAlias
ServerState
Our enum type `ServerState` has an underlying `int` type.
examples/enums/enums.go:13
Struct
argError
A custom error type usually has the suffix "Error".
examples/custom-errors/custom-errors.go:14
Struct
base
examples/struct-embedding/struct-embedding.go:11
Struct
circle
examples/interfaces/interfaces.go:22
Struct
container
A `container` _embeds_ a `base`. An embedding looks like a field without a name.
examples/struct-embedding/struct-embedding.go:21
Interface
describer
examples/struct-embedding/struct-embedding.go:52
Struct
element
examples/range-over-iterators/range-over-iterators.go:23
Struct
element
examples/generics/generics.go:32
Interface
geometry
Here's a basic interface for geometric shapes.
examples/interfaces/interfaces.go:12
Struct
person
This `person` struct type has `name` and `age` fields.
examples/structs/structs.go:10
Struct
point
examples/string-formatting/string-formatting.go:12
Struct
readOp
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
Struct
rect
examples/methods/methods.go:7
Struct
rect
For our example we'll implement this interface on `rect` and `circle` types.
examples/interfaces/interfaces.go:19
Struct
response1
We'll use these two structs to demonstrate encoding and decoding of custom types below.
examples/json/json.go:16
Struct
response2
Only exported fields will be encoded/decoded in JSON. Fields must start with capital letters to be exported.
examples/json/json.go:23
Struct
writeOp
examples/stateful-goroutines/stateful-goroutines.go:31