-
Notifications
You must be signed in to change notification settings - Fork 196
Permalink
Choose a base ref
{{ refName }}
default
Choose a head ref
{{ refName }}
default
Comparing changes
Choose two branches to see what’s changed or to start a new pull request.
If you need to, you can also or
learn more about diff comparisons.
Open a pull request
Create a new pull request by comparing changes across two branches. If you need to, you can also .
Learn more about diff comparisons here.
base repository: tinylib/msgp
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.4.0
Could not load branches
Nothing to show
Loading
Could not load tags
Nothing to show
{{ refName }}
default
Loading
...
head repository: tinylib/msgp
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.5.0
Could not load branches
Nothing to show
Loading
Could not load tags
Nothing to show
{{ refName }}
default
Loading
- 8 commits
- 23 files changed
- 2 contributors
Commits on Aug 28, 2025
-
Add Coerce functions to Number (#404)
* Add `Coerse` functions to `Number` Expands/replaces #143
Configuration menu - View commit details
-
Copy full SHA for bde549e - Browse repository at this point
Copy the full SHA bde549eView commit details -
Handle `atomic.Int64`, `atomic.Uint64`, `atomic.Int32`, `atomic.Uint32`, `atomic.Bool` types. Will use Load/Store for values. Values are serialized as their natural types. Fixes #400
Configuration menu - View commit details
-
Copy full SHA for 2f1ed81 - Browse repository at this point
Copy the full SHA 2f1ed81View commit details -
Add a convenience function to always get a number as float, even if converted. Fixes #152
Configuration menu - View commit details
-
Copy full SHA for 12a3436 - Browse repository at this point
Copy the full SHA 12a3436View commit details -
Allow for aliased types. By far the cleanest solution is to just use a replace directive. Fixes #250
Configuration menu - View commit details
-
Copy full SHA for ae1aabc - Browse repository at this point
Copy the full SHA ae1aabcView commit details
Commits on Aug 29, 2025
-
* Add `FooFromSlice` that will convert a slice of type to map[foo]struct{} * Add `Foo.AsSlice` that will return the set as a slice (sorted on sorted types). * Use `clear` to clear maps (Go 1.21) We can't use fancy `maps` and `slices` methods yet, since that is Go 1.23.Configuration menu - View commit details
-
Copy full SHA for 5817f93 - Browse repository at this point
Copy the full SHA 5817f93View commit details
Commits on Sep 17, 2025
-
Add array/map iterators (#403)
Allows to receive iterators for arrays or maps, so inputs can be directly iterated over. New functions in msgp: ```go // ReadArray returns an iterator that can be used to iterate over the elements // of an array in the MessagePack data while being read by the provided Reader. // The type parameter V specifies the type of the elements in the array. // The returned iterator implements the iter.Seq[V] interface, // allowing for sequential access to the array elements. func ReadArray[T any](m *Reader, readFn func() (T, error)) iter.Seq2[T, error] // WriteArray writes an array to the provided Writer. // The writeFn parameter specifies the function to use to write each element of the array. func WriteArray[T any](w *Writer, a []T, writeFn func(T) error) error // ReadMap returns an iterator that can be used to iterate over the elements // of a map in the MessagePack data while being read by the provided Reader. // The type parameters K and V specify the types of the keys and values in the map. // The returned iterator implements the iter.Seq2[K, V] interface, // allowing for sequential access to the map elements. // The returned function can be used to read any error that // occurred during iteration when iteration is done. func ReadMap[K, V any](m *Reader, readKey func() (K, error), readVal func() (V, error)) (iter.Seq2[K, V], func() error) // WriteMap writes a map to the provided Writer. // The writeKey and writeVal parameters specify the functions // to use to write each key and value of the map. func WriteMap[K comparable, V any](w *Writer, m map[K]V, writeKey func(K) error, writeVal func(V) error) error // WriteMapSorted writes a map to the provided Writer. // The keys of the map are sorted before writing. // This provides deterministic output, but will allocate to sort the keys. // The writeKey and writeVal parameters specify the functions // to use to write each key and value of the map. func WriteMapSorted[K cmp.Ordered, V any](w *Writer, m map[K]V, writeKey func(K) error, writeVal func(V) error) error // ReadArrayBytes returns an iterator that can be used to iterate over the elements // of an array in the MessagePack data while being read by the provided Reader. // The type parameter V specifies the type of the elements in the array. // After the iterator is exhausted, the remaining bytes in the buffer // and any error can be read by calling the returned function. func ReadArrayBytes[T any](b []byte, readFn func([]byte) (T, []byte, error)) (iter.Seq[T], func() (remain []byte, err error)) // AppendArray writes an array to the provided buffer. // The writeFn parameter specifies the function to use to write each element of the array. // The returned buffer contains the encoded array. // The function panics if the array is larger than math.MaxUint32 elements. func AppendArray[T any](b []byte, a []T, writeFn func(b []byte, v T) []byte) []byte // ReadMapBytes returns an iterator over key/value // pairs from a MessagePack map encoded in b. // The iterator yields K,V pairs, and this function also returns // a closure to get the remaining bytes and any error. func ReadMapBytes[K any, V any](b []byte, readK func([]byte) (K, []byte, error), readV func([]byte) (V, []byte, error)) (iter.Seq2[K, V], func() (remain []byte, err error)) // AppendMap writes a map to the provided buffer. // The writeK and writeV parameters specify the functions to use to write each key and value of the map. // The returned buffer contains the encoded map. // The function panics if the map is larger than math.MaxUint32 elements. func AppendMap[K comparable, V any](b []byte, m map[K]V, writeK func(b []byte, k K) []byte, writeV func(b []byte, v V) []byte) []byte // AppendMapSorted writes a map to the provided buffer. // Keys are sorted before writing. // This provides deterministic output, but will allocate to sort the keys. // The writeK and writeV parameters specify the functions to use to write each key and value of the map. // The returned buffer contains the encoded map. // The function panics if the map is larger than math.MaxUint32 elements. func AppendMapSorted[K cmp.Ordered, V any](b []byte, m map[K]V, writeK func(b []byte, k K) []byte, writeV func(b []byte, v V) []byte) []byte // DecoderFrom allows augmenting any type with a DecodeMsg method into a method // that reads from Reader and returns a T. // Provide an instance of T. This value isn't used. // See ReadArray/ReadMap "struct" examples for usage. func DecoderFrom[T any, PT DecodePtr[T]](r *Reader, _ T) func() (T, error) // DecoderFromBytes allows augmenting any type with an UnmarshalMsg // method into a method that reads from []byte and returns a T. // Provide an instance of T. This value isn't used. // See ReadArrayBytes or ReadMapBytes "struct" examples for usage. func DecoderFromBytes[T any, PT UnmarshalPtr[T]](_ T) func([]byte) (T, []byte, error) // EncoderTo allows augmenting any type with an EncodeMsg // method into a method that writes to Writer on each call. // Provide an instance of T. This value isn't used. // See ReadArray or ReadMap "struct" examples for usage. func EncoderTo[T any, _ FlexibleEncoder[T]](w *Writer, _ T) func(T) error // EncoderToBytes allows augmenting any type with a MarshalMsg method into a method // that reads from T and returns a []byte. // Provide an instance of T. This value isn't used. // See ReadArrayBytes or ReadMapBytes "struct" examples for usage. func EncoderToBytes[T any, _ FlexibleMarshaler[T]](_ T) func([]byte, T) []byte ``` Examples included in godoc.
Configuration menu - View commit details
-
Copy full SHA for 924e018 - Browse repository at this point
Copy the full SHA 924e018View commit details
Commits on Oct 24, 2025
-
msgp: fuzz test: fix overflow on 32-bit systems (#412)
On 32-bit systems, int(sz) can yield a negative value, which in turn leads to us passing a negative value to fwd.Reader.Next. (See philhofer/fwd#36.) The simplest fix here is just to check that the conversion doesn't yield a negative value.
Configuration menu - View commit details
-
Copy full SHA for e9e666a - Browse repository at this point
Copy the full SHA e9e666aView commit details
Commits on Oct 27, 2025
-
feat: Support generic types (#410)
This adds support for generic types. Say you have `type Foo[T any] struct`, you must add a constraint that it can be handled properly. The constraint is added with a built-in `type Foo[T any, _ msgp.RTFor[T]`. If `T` supports serialization this will work. Multiple types can be added, but each must have the constraint. Nested of types are supported. For example: ```go type Foo[T any, P msgp.RTFor[T]] struct { X Bar[T, P] `msg:",allownil"` } type Bar[T any, _ msgp.RTFor[T]] struct {...} ``` Notice how `P` can be used for a nested generic type. ## Limitations * Types cannot be primitives since they must support marshalling. It can however be an `type Int64 int` with generation should still work * Since we cannot reliably create instances with arbitrary types there are no tests. * The `msgp.RTFor[T]` type shouldn't be used for types in the struct since new instances cannot be created and can cause a runtime crash. * There will be warnings like: `warn: generics.go: GenericTest: A: possible non-local identifier: T`. * Some directives may exhibit unexpected behaviour. Not tested too deeply. ## Example ```go // MyStruct can be instantiated with any type T that supports marshaling. // T must be the base type and not a pointer to work. type MyStruct[T any, P msgp.RTFor[T]] struct { // Direct use of T A T C []T D map[string]T // T used for another generic. E MyStruct2[T, P, string] F []MyStruct2[T, P, string] G map[string]MyStruct2[T, P, string] // Same with pointers AP *T CP []*T DP map[string]*T EP *MyStruct2[T, P, string] FP []*MyStruct2[T, P, string] GP map[string]*MyStruct2[T, P, string] } // MyStruct2 can be used inside MyStruct. type MyStruct2[T any, P msgp.RTFor[T], B any] struct { A T } ```Configuration menu - View commit details
-
Copy full SHA for 9ed94a8 - Browse repository at this point
Copy the full SHA 9ed94a8View commit details
Loading
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff v1.4.0...v1.5.0