Skip to content

Commit

Permalink
v1.31.0 (#583)
Browse files Browse the repository at this point in the history
### Changed
- StreamReader ReadString() and WriteString() performance improvements.
  • Loading branch information
r-hang authored Jun 9, 2023
2 parents 36f2477 + 93c59eb commit 8259ee7
Show file tree
Hide file tree
Showing 69 changed files with 2,422 additions and 2,218 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.17.x", "1.18.x"]
go: ["1.19.x", "1.20.x"]
include:
- go: 1.18.x
- go: 1.20.x
latest: true

steps:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.31.0] - 2023-06-09
### Changed
- StreamReader ReadString() and WriteString() performance improvements.

## [1.30.0] - 2023-04-06
### Added
- AddTemplate template option.
Expand Down Expand Up @@ -434,6 +438,7 @@ this release.
### Added
- Initial release.

[1.31.0]: https://github.com/thriftrw/thriftrw-go/compare/v1.30.0...v1.31.0
[1.30.0]: https://github.com/thriftrw/thriftrw-go/compare/v1.29.2...v1.30.0
[1.29.2]: https://github.com/thriftrw/thriftrw-go/compare/v1.29.1...v1.29.2
[1.29.1]: https://github.com/thriftrw/thriftrw-go/compare/v1.29.0...v1.29.1
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ STATICCHECK = $(GOBIN)/staticcheck

LINT_EXCLUDES = \
gen/internal/tests/ \
gen/string.go \
idl/internal/lex.go \
idl/internal/y.go \
plugin/api/plugin.go \
Expand Down
2 changes: 1 addition & 1 deletion ast/annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
// Annotation represents a type annotation. Type annotations are key-value
// pairs in the form,
//
// (foo = "bar", baz = "qux")
// (foo = "bar", baz = "qux")
//
// They may be used to customize the generated code. Annotations are optional
// anywhere in the code where they're accepted and may be skipped completely.
Expand Down
16 changes: 8 additions & 8 deletions ast/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,28 +74,28 @@ func (r ConstantReference) pos() Position { return Position{Line: r.Line, Column

// ConstantBoolean is a boolean value specified in the Thrift file.
//
// true
// false
// true
// false
type ConstantBoolean bool

// ConstantInteger is an integer value specified in the Thrift file.
//
// 42
// 42
type ConstantInteger int64

// ConstantString is a string literal specified in the Thrift file.
//
// "hello world"
// "hello world"
type ConstantString string

// ConstantDouble is a floating point value specified in the Thrift file.
//
// 1.234
// 1.234
type ConstantDouble float64

// ConstantMap is a map literal from the Thrift file.
//
// {"a": 1, "b": 2}
// {"a": 1, "b": 2}
//
// Note that map literals can also be used to build structs.
type ConstantMap struct {
Expand All @@ -115,7 +115,7 @@ func (ConstantMapItem) node() {}

// ConstantList is a list literal from the Thrift file.
//
// [1, 2, 3]
// [1, 2, 3]
type ConstantList struct {
Items []ConstantValue
Line int
Expand All @@ -125,7 +125,7 @@ type ConstantList struct {
// ConstantReference is a reference to another constant value defined in the
// Thrift file.
//
// foo.bar
// foo.bar
type ConstantReference struct {
// Name of the referenced value.
Name string
Expand Down
67 changes: 33 additions & 34 deletions ast/definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type Definition interface {

// Constant is a constant declared in the Thrift file using a const statement.
//
// const i32 foo = 42
// const i32 foo = 42
type Constant struct {
Name string
Type Type
Expand All @@ -66,8 +66,8 @@ func (c *Constant) Info() DefinitionInfo {

// Typedef is used to define an alias for another type.
//
// typedef string UUID
// typedef i64 Timestamp (unit = "milliseconds")
// typedef string UUID
// typedef i64 Timestamp (unit = "milliseconds")
type Typedef struct {
Name string
Type Type
Expand Down Expand Up @@ -99,13 +99,13 @@ func (t *Typedef) Info() DefinitionInfo {

// Enum is a set of named integer values.
//
// enum Status { Enabled, Disabled }
// enum Status { Enabled, Disabled }
//
// enum Role {
// User = 1,
// Moderator = 2 (py.name = "Mod"),
// Admin = 3
// } (go.name = "UserRole")
// enum Role {
// User = 1,
// Moderator = 2 (py.name = "Mod"),
// Admin = 3
// } (go.name = "UserRole")
type Enum struct {
Name string
Items []*EnumItem
Expand Down Expand Up @@ -175,22 +175,22 @@ const (
//
// This type encompasses structs, unions, and exceptions.
//
// struct User {
// 1: required string name (min_length = "3")
// 2: optional Status status = Enabled;
// }
// struct User {
// 1: required string name (min_length = "3")
// 2: optional Status status = Enabled;
// }
//
// struct i128 {
// 1: required i64 high
// 2: required i64 low
// } (py.serializer = "foo.Int128Serializer")
// struct i128 {
// 1: required i64 high
// 2: required i64 low
// } (py.serializer = "foo.Int128Serializer")
//
// union Contents {
// 1: string plainText
// 2: binary pdf
// }
// union Contents {
// 1: string plainText
// 2: binary pdf
// }
//
// exception ServiceError { 1: required string message }
// exception ServiceError { 1: required string message }
type Struct struct {
Name string
Type StructureType
Expand Down Expand Up @@ -224,10 +224,10 @@ func (s *Struct) Info() DefinitionInfo {

// Service is a collection of functions.
//
// service KeyValue {
// void setValue(1: string key, 2: binary value)
// binary getValue(1: string key)
// } (router.serviceName = "key_value")
// service KeyValue {
// void setValue(1: string key, 2: binary value)
// binary getValue(1: string key)
// } (router.serviceName = "key_value")
type Service struct {
Name string
Functions []*Function
Expand Down Expand Up @@ -263,10 +263,10 @@ func (s *Service) Info() DefinitionInfo {

// Function is a single function inside a service.
//
// binary getValue(1: string key)
// throws (1: KeyNotFoundError notFound) (
// ttl.milliseconds = "250"
// )
// binary getValue(1: string key)
// throws (1: KeyNotFoundError notFound) (
// ttl.milliseconds = "250"
// )
type Function struct {
Name string
Parameters []*Field
Expand Down Expand Up @@ -312,10 +312,9 @@ const (
// Field is a single field inside a struct, union, exception, or a single item
// in the parameter or exception list of a function.
//
// 1: required i32 foo = 0
// 2: optional binary (max_length = "4096") bar
// 3: i64 baz (go.name = "qux")
//
// 1: required i32 foo = 0
// 2: optional binary (max_length = "4096") bar
// 3: i64 baz (go.name = "qux")
type Field struct {
ID int
// IDUnset indicates that a field identifier wasn't provided.
Expand Down
18 changes: 9 additions & 9 deletions ast/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@
// Package ast provides types and intefaces representing the abstract syntax
// tree for a single .thrift file.
//
// Docstrings
// # Docstrings
//
// Types which have a Doc field support parsing docstrings in the form,
// "/** ... */". For example, given the following,
//
// /**
// * Name of the user who composed this message.
// *
// * If unset, the comment was posted by an anonymous user.
// */
// 1: optional string author
// /**
// * Name of the user who composed this message.
// *
// * If unset, the comment was posted by an anonymous user.
// */
// 1: optional string author
//
// The Doc of the parsed Field will be,
//
// Name of the user who composed this message.
// Name of the user who composed this message.
//
// If unset, the comment was posted by an anonymous user.
// If unset, the comment was posted by an anonymous user.
package ast
8 changes: 4 additions & 4 deletions ast/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ type Header interface {

// Include is a request to include another Thrift file.
//
// include "shared.thrift"
// include "shared.thrift"
//
// thriftrw's custom Include-As syntax may be used to change the name under
// which the file is imported.
//
// include t "shared.thrift"
// include t "shared.thrift"
type Include struct {
Path string
Name string
Expand All @@ -62,7 +62,7 @@ func (i *Include) Info() HeaderInfo {

// CppInclude is a request to include a C++-specific header file.
//
// cpp_include "<unordered_map>"
// cpp_include "<unordered_map>"
type CppInclude struct {
Path string
Line int
Expand All @@ -84,7 +84,7 @@ func (i *CppInclude) Info() HeaderInfo {
// Namespace statements allow users to choose the package name used by the
// generated code in certain languages.
//
// namespace py foo.bar
// namespace py foo.bar
type Namespace struct {
Scope string
Name string
Expand Down
16 changes: 8 additions & 8 deletions ast/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ const (

// BaseType is a reference to a Thrift base type.
//
// bool, byte, i16, i32, i64, double, string, binary
// bool, byte, i16, i32, i64, double, string, binary
//
// All references to base types in the document may be followed by type
// annotations.
//
// bool (go.type = "int")
// bool (go.type = "int")
type BaseType struct {
// ID of the base type.
ID BaseTypeID
Expand Down Expand Up @@ -107,11 +107,11 @@ func (bt BaseType) String() string {

// MapType is a reference to a the Thrift map type.
//
// map<k, v>
// map<k, v>
//
// All references to map types may be followed by type annotations.
//
// map<string, list<i32>> (java.type = "MultiMap")
// map<string, list<i32>> (java.type = "MultiMap")
type MapType struct {
KeyType, ValueType Type
Annotations []*Annotation
Expand Down Expand Up @@ -143,11 +143,11 @@ func (mt MapType) String() string {

// ListType is a reference to the Thrift list type.
//
// list<a>
// list<a>
//
// All references to list types may be followed by type annotations.
//
// list<i64> (cpp.type = "vector")
// list<i64> (cpp.type = "vector")
type ListType struct {
ValueType Type
Annotations []*Annotation
Expand Down Expand Up @@ -178,11 +178,11 @@ func (lt ListType) String() string {

// SetType is a reference to the Thrift set type.
//
// set<a>
// set<a>
//
// All references to set types may be followed by type annotations.
//
// set<string> (js.type = "list")
// set<string> (js.type = "list")
type SetType struct {
ValueType Type
Annotations []*Annotation
Expand Down
5 changes: 2 additions & 3 deletions cmd/thriftbreak/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ package main
import (
"bytes"
"io"
"io/ioutil"
"os"
"testing"

Expand Down Expand Up @@ -90,7 +89,7 @@ func TestThriftBreakIntegration(t *testing.T) {
tmpDir := t.TempDir()
breaktest.CreateRepoAndCommit(t, tmpDir, from, to, remove)

f, err := ioutil.TempFile(tmpDir, "stdout")
f, err := os.CreateTemp(tmpDir, "stdout")
require.NoError(t, err, "create temporary file")
defer func(oldStdout *os.File) {
assert.NoError(t, f.Close())
Expand All @@ -103,7 +102,7 @@ func TestThriftBreakIntegration(t *testing.T) {
require.Error(t, err, "expected an error with Thrift backwards incompatible changes")
assert.EqualError(t, err, "found 5 issues")

stderr, err := ioutil.ReadFile(f.Name())
stderr, err := os.ReadFile(f.Name())
require.NoError(t, err)

out := string(stderr)
Expand Down
5 changes: 2 additions & 3 deletions cmd/thriftrw-list-deps/main_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"io/ioutil"
"os"
"path/filepath"
"sort"
Expand All @@ -12,7 +11,7 @@ import (
)

func TestThriftrwListDeps(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "")
tmpDir, err := os.MkdirTemp("", "")
require.NoError(t, err)

defer os.RemoveAll(tmpDir)
Expand All @@ -29,7 +28,7 @@ include "./c.thrift"`,
path := filepath.Join(tmpDir, name)
err = os.MkdirAll(filepath.Dir(path), 0755)
require.NoError(t, err)
err = ioutil.WriteFile(path, []byte(content), 0644)
err = os.WriteFile(path, []byte(content), 0644)
require.NoError(t, err)
}

Expand Down
Loading

0 comments on commit 8259ee7

Please sign in to comment.