This moves the type off from the value and instead we compute it as we ask for.
This also changes how we detect cycles. If a named struct contains a struct with the
same name we now create a cycle between them. This also means that cycle types
now take a string and not a number.
For encoding we no longer write the type with the value (unless it is a types.Ref).
This is a format change so this takes us to 7.6
Fixes#3328Fixes#3325Fixes#3324Fixes#3323
BREAKING CHANGE
This removes the `Type()` method from the `types.Value` interface.
Instead use the `types.TypeOf(v types.Value) bool` function.
Fixes#3324
* Update struct in memory representation
To contain struct name and field names.
This is in preparation for removing types from the value.
Towards ##3324
* Rename structFields to structTypeFields
* Undo change in vendoring
* searchField and copy
This adds optional fields to structs.
New version: 7.4
To create a struct type with optional fields use types.MakeStructType2
There are some API changes in this commit and there will be some more in followup commits.
Fixes#2327
* Support marshaling from and unmarshaling to *types.Type
* Incorporate code review suggestions.
- Use fallthrough in switch
- Update decode godoc to spec *types.Type handling. Godoc for encode is fine as is.
toward: #2889
-
Introduce photo-dedup-by-date
This program deduplicates photos by the date they were taken. It considers two photos a group if they were separated by less than 5 seconds.
Make the name of the Noms struct start with a capital letter.
When unmarshalling a struct we now ignore the case.
This is a breaking change. If you previously marshalled a Go struct with a lower case name (ie "abc") the Noms struct we generate now has the name "Abc" (previously the name was "abc")
Towards #2376
When unmarshalling onto interface{}` the following rules are used:
- `types.Bool` -> `bool`
- `types.List` -> `[]T`, where `T` is determined recursively using the same rules.
- `types.Map` -> `map[T]V`, where `T` and `V` is determined recursively using the same rules.
- `types.Number` -> `float64`
- `types.String` -> `string`
- `types.Union` -> `interface`
- Everything else an error
Towards #2376
Basic support for creating Noms value from Go values as well as reading
Noms values onto Go values.
Typical usage:
```
// Go to Noms
type T struct {
S string
N int32
}
nomsVal, err := marshal.Marshal(T{"Hi", 42})
// Noms to Go
var goVal T
err = marshal.Unmarshal(types.NewStruct("T", types.StructData{
"S": types.String("Bye"),
"N": types.Number(555),
}, &goVal)
```
Fixes#1591