Skip to content

Commit

Permalink
Merge pull request #4 from desertbit/f-upstream-merge
Browse files Browse the repository at this point in the history
upstream merge
  • Loading branch information
r0l1 authored Apr 19, 2024
2 parents 1876de0 + 18acb44 commit d7b05f1
Show file tree
Hide file tree
Showing 70 changed files with 1,727 additions and 640 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: test

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
workflow_dispatch:
push:
branches:
- 'master'
- 'main'
tags:
- 'v*'
pull_request:

permissions:
contents: read

jobs:
test:
strategy:
matrix:
go-version: [1.18.x, 1.19.x, 1.20.x, 1.21.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 10
steps:
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
- name: test
run: make ci
39 changes: 39 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: validate

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
workflow_dispatch:
push:
branches:
- 'master'
- 'main'
tags:
- 'v*'
pull_request:

permissions:
contents: read

jobs:
linters:
strategy:
matrix:
go-version: [1.21.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 10
steps:
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
- name: prepare generated code
run: make prepare
- name: lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.55.1
args: --print-resources-usage --timeout=10m --verbose
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
linters:
disable:
- errcheck
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

22 changes: 15 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SHELL := /bin/bash

BIN = $(GOBIN)/msgp

.PHONY: clean wipe install get-deps bench all
.PHONY: clean wipe install get-deps bench all ci prepare

$(BIN): */*.go
@go install ./...
Expand Down Expand Up @@ -43,12 +43,20 @@ get-deps:

all: install $(GGEN) $(MGEN)

# travis CI enters here
travis:
arch
if [ `arch` == 'x86_64' ]; then sudo apt update; sudo apt install build-essential; wget https://github.com/tinygo-org/tinygo/releases/download/v0.18.0/tinygo_0.18.0_amd64.deb; sudo dpkg -i tinygo_0.18.0_amd64.deb; export PATH=$PATH:/usr/local/tinygo/bin; fi
go get -d -t ./...
go build -o "$${GOPATH%%:*}/bin/msgp" .
# Prepare generated code to be used for linting and testing in CI
prepare:
go install .
go generate ./msgp
go generate ./_generated

# CI enters here
ci: prepare
arch
if [ `arch` == 'x86_64' ]; then \
sudo apt-get -y -q update; \
sudo apt-get -y -q install build-essential; \
wget -q https://github.com/tinygo-org/tinygo/releases/download/v0.30.0/tinygo_0.30.0_amd64.deb; \
sudo dpkg -i tinygo_0.30.0_amd64.deb; \
export PATH=$$PATH:/usr/local/tinygo/bin; \
fi
go test -v ./... ./_generated
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
MessagePack Code Generator [![Build Status](https://travis-ci.org/desertbit/msgp.svg?branch=master)](https://travis-ci.org/desertbit/msgp)

This is a code generation tool and serialization library for [MessagePack](http://msgpack.org). You can read more about MessagePack [in the wiki](http://github.com/desertbit/msgp/wiki), or at [msgpack.org](http://msgpack.org).
=======
MessagePack Code Generator
=======

[![Go Reference](https://pkg.go.dev/badge/github.com/desertbit/msgp.svg)](https://pkg.go.dev/github.com/desertbit/msgp)
[![test](https://github.com/desertbit/msgp/actions/workflows/test.yml/badge.svg)](https://github.com/desertbit/msgp/actions/workflows/test.yml)
[![validate](https://github.com/desertbit/msgp/actions/workflows/validate.yml/badge.svg)](https://github.com/desertbit/msgp/actions/workflows/validate.yml)

This is a code generation tool and serialization library for [MessagePack](http://msgpack.org). You can read more about MessagePack [in the wiki](http://github.com/desertbit/msgp/wiki), or at [msgpack.org](http://msgpack.org).

### Why?

- Use Go as your schema language
- Performance
- [JSON interop](http://godoc.org/github.com/desertbit/msgp/msgp#CopyToJSON)
- [JSON interop](https://pkg.go.dev/github.com/desertbit/msgp/msgp#CopyToJSON)
- [User-defined extensions](http://github.com/desertbit/msgp/wiki/Using-Extensions)
- Type safety
- Encoding flexibility
Expand Down
230 changes: 230 additions & 0 deletions _generated/allownil.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
package _generated

import "time"

//go:generate msgp

type AllowNil0 struct {
ABool bool `msg:"abool,allownil"`
AInt int `msg:"aint,allownil"`
AInt8 int8 `msg:"aint8,allownil"`
AInt16 int16 `msg:"aint16,allownil"`
AInt32 int32 `msg:"aint32,allownil"`
AInt64 int64 `msg:"aint64,allownil"`
AUint uint `msg:"auint,allownil"`
AUint8 uint8 `msg:"auint8,allownil"`
AUint16 uint16 `msg:"auint16,allownil"`
AUint32 uint32 `msg:"auint32,allownil"`
AUint64 uint64 `msg:"auint64,allownil"`
AFloat32 float32 `msg:"afloat32,allownil"`
AFloat64 float64 `msg:"afloat64,allownil"`
AComplex64 complex64 `msg:"acomplex64,allownil"`
AComplex128 complex128 `msg:"acomplex128,allownil"`

ANamedBool bool `msg:"anamedbool,allownil"`
ANamedInt int `msg:"anamedint,allownil"`
ANamedFloat64 float64 `msg:"anamedfloat64,allownil"`

AMapStrStr map[string]string `msg:"amapstrstr,allownil"`

APtrNamedStr *NamedString `msg:"aptrnamedstr,allownil"`

AString string `msg:"astring,allownil"`
ANamedString string `msg:"anamedstring,allownil"`
AByteSlice []byte `msg:"abyteslice,allownil"`

ASliceString []string `msg:"aslicestring,allownil"`
ASliceNamedString []NamedString `msg:"aslicenamedstring,allownil"`

ANamedStruct NamedStructAN `msg:"anamedstruct,allownil"`
APtrNamedStruct *NamedStructAN `msg:"aptrnamedstruct,allownil"`

AUnnamedStruct struct {
A string `msg:"a,allownil"`
} `msg:"aunnamedstruct,allownil"` // allownil not supported on unnamed struct

EmbeddableStructAN `msg:",flatten,allownil"` // embed flat

EmbeddableStruct2AN `msg:"embeddablestruct2,allownil"` // embed non-flat

AArrayInt [5]int `msg:"aarrayint,allownil"` // not supported

ATime time.Time `msg:"atime,allownil"`
}

type AllowNil1 struct {
ABool []bool `msg:"abool,allownil"`
AInt []int `msg:"aint,allownil"`
AInt8 []int8 `msg:"aint8,allownil"`
AInt16 []int16 `msg:"aint16,allownil"`
AInt32 []int32 `msg:"aint32,allownil"`
AInt64 []int64 `msg:"aint64,allownil"`
AUint []uint `msg:"auint,allownil"`
AUint8 []uint8 `msg:"auint8,allownil"`
AUint16 []uint16 `msg:"auint16,allownil"`
AUint32 []uint32 `msg:"auint32,allownil"`
AUint64 []uint64 `msg:"auint64,allownil"`
AFloat32 []float32 `msg:"afloat32,allownil"`
AFloat64 []float64 `msg:"afloat64,allownil"`
AComplex64 []complex64 `msg:"acomplex64,allownil"`
AComplex128 []complex128 `msg:"acomplex128,allownil"`

ANamedBool []bool `msg:"anamedbool,allownil"`
ANamedInt []int `msg:"anamedint,allownil"`
ANamedFloat64 []float64 `msg:"anamedfloat64,allownil"`

AMapStrStr map[string]string `msg:"amapstrstr,allownil"`

APtrNamedStr *NamedString `msg:"aptrnamedstr,allownil"`

AString []string `msg:"astring,allownil"`
ANamedString []string `msg:"anamedstring,allownil"`
AByteSlice []byte `msg:"abyteslice,allownil"`

ASliceString []string `msg:"aslicestring,allownil"`
ASliceNamedString []NamedString `msg:"aslicenamedstring,allownil"`

ANamedStruct NamedStructAN `msg:"anamedstruct,allownil"`
APtrNamedStruct *NamedStructAN `msg:"aptrnamedstruct,allownil"`

AUnnamedStruct struct {
A []string `msg:"a,allownil"`
} `msg:"aunnamedstruct,allownil"`

*EmbeddableStructAN `msg:",flatten,allownil"` // embed flat

*EmbeddableStruct2AN `msg:"embeddablestruct2,allownil"` // embed non-flat

AArrayInt [5]int `msg:"aarrayint,allownil"` // not supported

ATime *time.Time `msg:"atime,allownil"`
}

type EmbeddableStructAN struct {
SomeEmbed []string `msg:"someembed,allownil"`
}

type EmbeddableStruct2AN struct {
SomeEmbed2 []string `msg:"someembed2,allownil"`
}

type NamedStructAN struct {
A []string `msg:"a,allownil"`
B []string `msg:"b,allownil"`
}

type AllowNilHalfFull struct {
Field00 []string `msg:"field00,allownil"`
Field01 []string `msg:"field01"`
Field02 []string `msg:"field02,allownil"`
Field03 []string `msg:"field03"`
}

type AllowNilLotsOFields struct {
Field00 []string `msg:"field00,allownil"`
Field01 []string `msg:"field01,allownil"`
Field02 []string `msg:"field02,allownil"`
Field03 []string `msg:"field03,allownil"`
Field04 []string `msg:"field04,allownil"`
Field05 []string `msg:"field05,allownil"`
Field06 []string `msg:"field06,allownil"`
Field07 []string `msg:"field07,allownil"`
Field08 []string `msg:"field08,allownil"`
Field09 []string `msg:"field09,allownil"`
Field10 []string `msg:"field10,allownil"`
Field11 []string `msg:"field11,allownil"`
Field12 []string `msg:"field12,allownil"`
Field13 []string `msg:"field13,allownil"`
Field14 []string `msg:"field14,allownil"`
Field15 []string `msg:"field15,allownil"`
Field16 []string `msg:"field16,allownil"`
Field17 []string `msg:"field17,allownil"`
Field18 []string `msg:"field18,allownil"`
Field19 []string `msg:"field19,allownil"`
Field20 []string `msg:"field20,allownil"`
Field21 []string `msg:"field21,allownil"`
Field22 []string `msg:"field22,allownil"`
Field23 []string `msg:"field23,allownil"`
Field24 []string `msg:"field24,allownil"`
Field25 []string `msg:"field25,allownil"`
Field26 []string `msg:"field26,allownil"`
Field27 []string `msg:"field27,allownil"`
Field28 []string `msg:"field28,allownil"`
Field29 []string `msg:"field29,allownil"`
Field30 []string `msg:"field30,allownil"`
Field31 []string `msg:"field31,allownil"`
Field32 []string `msg:"field32,allownil"`
Field33 []string `msg:"field33,allownil"`
Field34 []string `msg:"field34,allownil"`
Field35 []string `msg:"field35,allownil"`
Field36 []string `msg:"field36,allownil"`
Field37 []string `msg:"field37,allownil"`
Field38 []string `msg:"field38,allownil"`
Field39 []string `msg:"field39,allownil"`
Field40 []string `msg:"field40,allownil"`
Field41 []string `msg:"field41,allownil"`
Field42 []string `msg:"field42,allownil"`
Field43 []string `msg:"field43,allownil"`
Field44 []string `msg:"field44,allownil"`
Field45 []string `msg:"field45,allownil"`
Field46 []string `msg:"field46,allownil"`
Field47 []string `msg:"field47,allownil"`
Field48 []string `msg:"field48,allownil"`
Field49 []string `msg:"field49,allownil"`
Field50 []string `msg:"field50,allownil"`
Field51 []string `msg:"field51,allownil"`
Field52 []string `msg:"field52,allownil"`
Field53 []string `msg:"field53,allownil"`
Field54 []string `msg:"field54,allownil"`
Field55 []string `msg:"field55,allownil"`
Field56 []string `msg:"field56,allownil"`
Field57 []string `msg:"field57,allownil"`
Field58 []string `msg:"field58,allownil"`
Field59 []string `msg:"field59,allownil"`
Field60 []string `msg:"field60,allownil"`
Field61 []string `msg:"field61,allownil"`
Field62 []string `msg:"field62,allownil"`
Field63 []string `msg:"field63,allownil"`
Field64 []string `msg:"field64,allownil"`
Field65 []string `msg:"field65,allownil"`
Field66 []string `msg:"field66,allownil"`
Field67 []string `msg:"field67,allownil"`
Field68 []string `msg:"field68,allownil"`
Field69 []string `msg:"field69,allownil"`
}

type AllowNil10 struct {
Field00 []string `msg:"field00,allownil"`
Field01 []string `msg:"field01,allownil"`
Field02 []string `msg:"field02,allownil"`
Field03 []string `msg:"field03,allownil"`
Field04 []string `msg:"field04,allownil"`
Field05 []string `msg:"field05,allownil"`
Field06 []string `msg:"field06,allownil"`
Field07 []string `msg:"field07,allownil"`
Field08 []string `msg:"field08,allownil"`
Field09 []string `msg:"field09,allownil"`
}

type NotAllowNil10 struct {
Field00 []string `msg:"field00"`
Field01 []string `msg:"field01"`
Field02 []string `msg:"field02"`
Field03 []string `msg:"field03"`
Field04 []string `msg:"field04"`
Field05 []string `msg:"field05"`
Field06 []string `msg:"field06"`
Field07 []string `msg:"field07"`
Field08 []string `msg:"field08"`
Field09 []string `msg:"field09"`
}

type AllowNilOmitEmpty struct {
Field00 []string `msg:"field00,allownil,omitempty"`
Field01 []string `msg:"field01,allownil"`
}

type AllowNilOmitEmpty2 struct {
Field00 []string `msg:"field00,allownil,omitempty"`
Field01 []string `msg:"field01,allownil,omitempty"`
}
Loading

0 comments on commit d7b05f1

Please sign in to comment.