mirror of
https://github.com/foomo/gotsrpc.git
synced 2025-10-16 12:35:35 +00:00
Merge branch 'main' into dependabot/github_actions/github-actions-a8d1d1367e
This commit is contained in:
commit
7ab2de3260
27
.github/workflows/test.yml
vendored
27
.github/workflows/test.yml
vendored
@ -4,9 +4,7 @@ on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
merge_group:
|
||||
branches: [ main ]
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
@ -17,6 +15,11 @@ env:
|
||||
GOFLAGS: -mod=readonly
|
||||
GOPROXY: https://proxy.golang.org
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
checks: write
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
@ -28,10 +31,24 @@ jobs:
|
||||
check-latest: true
|
||||
go-version-file: go.mod
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
|
||||
- name: Run yarn install
|
||||
working-directory: example
|
||||
run: yarn install
|
||||
|
||||
- name: Run go mod tidy
|
||||
run: |
|
||||
make tidy
|
||||
git diff --exit-code
|
||||
|
||||
- uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
working-directory: ${{ matrix.gomod }}
|
||||
|
||||
- name: Run tests
|
||||
run: go test -v ./...
|
||||
run: make test
|
||||
|
||||
- name: Make examples
|
||||
run: |
|
||||
make examples
|
||||
git diff --exit-code
|
||||
|
||||
|
||||
30
.gitignore
vendored
30
.gitignore
vendored
@ -1,7 +1,27 @@
|
||||
!.git*
|
||||
/vendor/
|
||||
dist/
|
||||
.idea
|
||||
.*
|
||||
bin/
|
||||
dist/
|
||||
tmp/
|
||||
**/node_modules/
|
||||
|
||||
## Git ##
|
||||
!.gitignore
|
||||
!.gitkeep
|
||||
|
||||
## GitHub ##
|
||||
!.github/
|
||||
|
||||
## Node ##
|
||||
**/node_modules/
|
||||
|
||||
## TypeScript ###
|
||||
*.tsbuildinfo
|
||||
|
||||
## Goreleaser ###
|
||||
!.goreleaser.yaml
|
||||
|
||||
### Go ###
|
||||
/go.mod
|
||||
/go.sum
|
||||
/go.work
|
||||
/go.work.sum
|
||||
!.golangci.yaml
|
||||
|
||||
@ -52,6 +52,19 @@ linters:
|
||||
- unused # (megacheck): Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false]
|
||||
|
||||
# Disabled by default linters:
|
||||
#- canonicalheader # canonicalheader checks whether net/http.Header uses canonical header [fast: false, auto-fix: false]
|
||||
#- dupword # checks for duplicate words in the source code [fast: true, auto-fix: false]
|
||||
#- fatcontext # detects nested contexts in loops and function literals [fast: false, auto-fix: false]
|
||||
#- iface # Detect the incorrect use of interfaces, helping developers avoid interface pollution. [fast: false, auto-fix: false]
|
||||
#- interfacebloat # A linter that checks the number of methods inside an interface. [fast: true, auto-fix: false]
|
||||
#- perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative. [fast: false, auto-fix: false]
|
||||
#- reassign # Checks that package variables are not reassigned [fast: false, auto-fix: false]
|
||||
#- recvcheck # checks for receiver type consistency [fast: false, auto-fix: false]
|
||||
#- sloglint # ensure consistent code style when using log/slog [fast: false, auto-fix: false]
|
||||
#- tagalign # check that struct tags are well aligned [fast: true, auto-fix: true]
|
||||
#- zerologlint # Detects the wrong usage of `zerolog` that a user forgets to dispatch with `Send` or `Msg` [fast: false, auto-fix: false]
|
||||
|
||||
|
||||
- asasalint # check for pass []any as any in variadic func(...any) [fast: false, auto-fix: false]
|
||||
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers [fast: true, auto-fix: false]
|
||||
- bidichk # Checks for dangerous unicode character sequences [fast: true, auto-fix: false]
|
||||
@ -67,10 +80,8 @@ linters:
|
||||
- errchkjson # Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted. [fast: false, auto-fix: false]
|
||||
- errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`. [fast: false, auto-fix: false]
|
||||
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13. [fast: false, auto-fix: false]
|
||||
- execinquery # execinquery is a linter about query string checker in Query function which reads your Go src files and warning it finds [fast: false, auto-fix: false]
|
||||
- exhaustive # check exhaustiveness of enum switch statements [fast: false, auto-fix: false]
|
||||
#- exhaustruct # Checks if all structure fields are initialized [fast: false, auto-fix: false]
|
||||
- exportloopref # checks for pointers to enclosing loop variables [fast: false, auto-fix: false]
|
||||
#- forbidigo # Forbids identifiers [fast: true, auto-fix: false]
|
||||
- forcetypeassert # finds forced type assertions [fast: true, auto-fix: false]
|
||||
#- funlen # Tool for detection of long functions [fast: true, auto-fix: false]
|
||||
@ -83,12 +94,12 @@ linters:
|
||||
#- gocyclo # Computes and checks the cyclomatic complexity of functions [fast: true, auto-fix: false]
|
||||
#- godot # Check if comments end in a period [fast: true, auto-fix: true]
|
||||
#- godox # Tool for detection of FIXME, TODO and other comment keywords [fast: true, auto-fix: false]
|
||||
#- goerr113 # Golang linter to check the errors handling expressions [fast: false, auto-fix: false]
|
||||
#- err113: Go linter to check the errors handling expressions [fast: false, auto-fix: false]
|
||||
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification [fast: true, auto-fix: true]
|
||||
#- gofumpt # Gofumpt checks whether code was gofumpt-ed. [fast: true, auto-fix: true]
|
||||
- goheader # Checks is file header matches to pattern [fast: true, auto-fix: false]
|
||||
- goimports # In addition to fixing imports, goimports also formats your code in the same style as gofmt. [fast: true, auto-fix: true]
|
||||
#- gomnd # An analyzer to detect magic numbers. [fast: true, auto-fix: false]
|
||||
#- mnd: An analyzer to detect magic numbers. [fast: true, auto-fix: false]
|
||||
#- gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod. [fast: true, auto-fix: false]
|
||||
- gomodguard # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations. [fast: true, auto-fix: false]
|
||||
- goprintffuncname # Checks that printf-like functions are named with `f` at the end [fast: true, auto-fix: false]
|
||||
|
||||
7
Makefile
7
Makefile
@ -10,6 +10,7 @@ test:
|
||||
install:
|
||||
go install cmd/gotsrpc/gotsrpc.go
|
||||
|
||||
.PHONY: install.debug
|
||||
## Run go install with debug
|
||||
install.debug:
|
||||
go install -gcflags "all=-N -l" cmd/gotsrpc/gotsrpc.go
|
||||
@ -19,6 +20,12 @@ install.debug:
|
||||
outdated:
|
||||
go list -u -m -json all | go-mod-outdated -update -direct
|
||||
|
||||
.PHONY: build.debug
|
||||
## Build binary in debug mode
|
||||
build.debug:
|
||||
rm -f bin/gotsrpc
|
||||
go build -gcflags "all=-N -l" -o bin/gotsrpc cmd/gotsrpc/gotsrpc.go
|
||||
|
||||
## === Tools ===
|
||||
|
||||
EXAMPLES=basic errors monitor nullable union time
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
/* eslint:disable */
|
||||
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
|
||||
import * as github_com_foomo_gotsrpc_v2_example_basic_service from './service-vo'; // ./client/src/service-vo.ts to ./client/src/service-vo.ts
|
||||
|
||||
// github.com/foomo/gotsrpc/v2/example/basic/service.Float32Type
|
||||
export enum Float32Type {
|
||||
Float32AType = 1,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module:
|
||||
name: github.com/foomo/gotsrpc/v2/example/basic
|
||||
path: ./
|
||||
name: github.com/foomo/gotsrpc/v2
|
||||
path: ../../
|
||||
|
||||
targets:
|
||||
basic:
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
/* eslint:disable */
|
||||
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
|
||||
import * as github_com_foomo_gotsrpc_v2_example_errors_service_frontend from './service-vo'; // ./client/src/service-vo.ts to ./client/src/service-vo.ts
|
||||
|
||||
// github.com/foomo/gotsrpc/v2/example/errors/service/frontend.ErrMulti
|
||||
export type ErrMulti = (typeof github_com_foomo_gotsrpc_v2_example_errors_service_frontend.ErrMultiA) & (typeof github_com_foomo_gotsrpc_v2_example_errors_service_frontend.ErrMultiB)
|
||||
export const ErrMulti = { ...github_com_foomo_gotsrpc_v2_example_errors_service_frontend.ErrMultiA, ...github_com_foomo_gotsrpc_v2_example_errors_service_frontend.ErrMultiB }
|
||||
export type ErrMulti = typeof ErrMulti
|
||||
// github.com/foomo/gotsrpc/v2/example/errors/service/frontend.ErrMultiA
|
||||
export enum ErrMultiA {
|
||||
One = "one",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module:
|
||||
name: github.com/foomo/gotsrpc/v2/example/errors
|
||||
path: ./
|
||||
name: github.com/foomo/gotsrpc/v2
|
||||
path: ../../
|
||||
|
||||
targets:
|
||||
frontend:
|
||||
|
||||
@ -21,8 +21,8 @@ type (
|
||||
)
|
||||
|
||||
const (
|
||||
ScalarErrorOne ScalarError = "scalar error one" //nolint:errname
|
||||
ScalarErrorTwo ScalarError = "scalar error two" //nolint:errname
|
||||
ScalarErrorOne ScalarError = "scalar error one"
|
||||
ScalarErrorTwo ScalarError = "scalar error two"
|
||||
)
|
||||
|
||||
func NewScalarError(e ScalarError) *ScalarError {
|
||||
|
||||
@ -39,8 +39,8 @@ type (
|
||||
)
|
||||
|
||||
const (
|
||||
ScalarOne ScalarError = "one" //nolint:errname
|
||||
ScalarTwo ScalarError = "two" //nolint:errname
|
||||
ScalarOne ScalarError = "one"
|
||||
ScalarTwo ScalarError = "two"
|
||||
|
||||
ScalarAOne ScalarA = "one"
|
||||
ScalarATwo ScalarA = "two"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module:
|
||||
name: github.com/foomo/gotsrpc/v2/example/monitor
|
||||
path: ./
|
||||
name: github.com/foomo/gotsrpc/v2
|
||||
path: ../../
|
||||
|
||||
targets:
|
||||
monitor:
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
/* eslint:disable */
|
||||
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
|
||||
import * as github_com_foomo_gotsrpc_v2_example_nullable_service from './service-vo'; // ./client/src/service-vo.ts to ./client/src/service-vo.ts
|
||||
|
||||
// github.com/foomo/gotsrpc/v2/example/nullable/service.ACustomType
|
||||
export enum ACustomType {
|
||||
One = "one",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module:
|
||||
name: github.com/foomo/gotsrpc/v2/example/nullable
|
||||
path: ./
|
||||
name: github.com/foomo/gotsrpc/v2
|
||||
path: ../../
|
||||
|
||||
targets:
|
||||
nullable:
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
"version": "0.1.0",
|
||||
"name": "@foomo/gotsrpc-examples",
|
||||
"devDependencies": {
|
||||
"typescript": "^4.6.2"
|
||||
"typescript": "5.6.3"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
/* eslint:disable */
|
||||
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
|
||||
import * as github_com_foomo_gotsrpc_v2_example_time_service from './service-vo-service'; // ./client/src/service-client.ts to ./client/src/service-vo-service.ts
|
||||
import * as time from './service-vo-time'; // ./client/src/service-client.ts to ./client/src/service-vo-time.ts
|
||||
|
||||
export class ServiceClient {
|
||||
public static defaultEndpoint = "/service";
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
/* eslint:disable */
|
||||
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
|
||||
import * as github_com_foomo_gotsrpc_v2_example_time_service from './service-vo-service'; // ./client/src/service-vo-service.ts to ./client/src/service-vo-service.ts
|
||||
import * as time from './service-vo-time'; // ./client/src/service-vo-service.ts to ./client/src/service-vo-time.ts
|
||||
|
||||
// github.com/foomo/gotsrpc/v2/example/time/service.TimeStruct
|
||||
export interface TimeStruct {
|
||||
time:number;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/* eslint:disable */
|
||||
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
|
||||
import * as github_com_foomo_gotsrpc_v2_example_time_service from './service-vo-service'; // ./client/src/service-vo-time.ts to ./client/src/service-vo-service.ts
|
||||
import * as time from './service-vo-time'; // ./client/src/service-vo-time.ts to ./client/src/service-vo-time.ts
|
||||
|
||||
// time.Time
|
||||
export interface Time {
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module:
|
||||
name: github.com/foomo/gotsrpc/v2/example/time
|
||||
path: ./
|
||||
name: github.com/foomo/gotsrpc/v2
|
||||
path: ../../
|
||||
|
||||
targets:
|
||||
time:
|
||||
|
||||
@ -47,4 +47,4 @@ function assertExhaustive(
|
||||
message: string = 'msg'
|
||||
): never {
|
||||
throw new Error(message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
/* eslint:disable */
|
||||
// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT.
|
||||
import * as github_com_foomo_gotsrpc_v2_example_union_service from './service-vo'; // ./client/src/service-vo.ts to ./client/src/service-vo.ts
|
||||
|
||||
// github.com/foomo/gotsrpc/v2/example/union/service.InlineStruct
|
||||
export interface InlineStruct extends github_com_foomo_gotsrpc_v2_example_union_service.InlineStructA , github_com_foomo_gotsrpc_v2_example_union_service.InlineStructB {
|
||||
value:string;
|
||||
@ -19,7 +20,8 @@ export interface InlineStructPtr extends Partial<github_com_foomo_gotsrpc_v2_exa
|
||||
value:string;
|
||||
}
|
||||
// github.com/foomo/gotsrpc/v2/example/union/service.UnionString
|
||||
export type UnionString = (typeof github_com_foomo_gotsrpc_v2_example_union_service.UnionStringA) & (typeof github_com_foomo_gotsrpc_v2_example_union_service.UnionStringB)
|
||||
export const UnionString = { ...github_com_foomo_gotsrpc_v2_example_union_service.UnionStringA, ...github_com_foomo_gotsrpc_v2_example_union_service.UnionStringB }
|
||||
export type UnionString = typeof UnionString
|
||||
// github.com/foomo/gotsrpc/v2/example/union/service.UnionStringA
|
||||
export enum UnionStringA {
|
||||
One = "one",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module:
|
||||
name: github.com/foomo/gotsrpc/v2/example/union
|
||||
path: ./
|
||||
name: github.com/foomo/gotsrpc/v2
|
||||
path: ../../
|
||||
|
||||
targets:
|
||||
union:
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
typescript@^4.6.2:
|
||||
version "4.6.2"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.2.tgz#fe12d2727b708f4eef40f51598b3398baa9611d4"
|
||||
integrity sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg==
|
||||
typescript@5.6.3:
|
||||
version "5.6.3"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.6.3.tgz#5f3449e31c9d94febb17de03cc081dd56d81db5b"
|
||||
integrity sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==
|
||||
|
||||
9
go.mod
9
go.mod
@ -7,12 +7,12 @@ require (
|
||||
github.com/iancoleman/strcase v0.2.0 // Be aware of https://github.com/iancoleman/strcase/pull/49
|
||||
github.com/mitchellh/mapstructure v1.5.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/prometheus/client_golang v1.19.0
|
||||
github.com/prometheus/client_golang v1.19.1
|
||||
github.com/stretchr/testify v1.9.0
|
||||
github.com/ugorji/go/codec v1.2.12
|
||||
github.com/valyala/gorpc v0.0.0-20160519171614-908281bef774
|
||||
golang.org/x/mod v0.17.0
|
||||
golang.org/x/tools v0.20.0
|
||||
golang.org/x/mod v0.20.0
|
||||
golang.org/x/tools v0.23.0
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
)
|
||||
|
||||
@ -24,7 +24,8 @@ require (
|
||||
github.com/prometheus/client_model v0.5.0 // indirect
|
||||
github.com/prometheus/common v0.48.0 // indirect
|
||||
github.com/prometheus/procfs v0.12.0 // indirect
|
||||
golang.org/x/sys v0.19.0 // indirect
|
||||
golang.org/x/sync v0.7.0 // indirect
|
||||
golang.org/x/sys v0.22.0 // indirect
|
||||
google.golang.org/protobuf v1.33.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
16
go.sum
16
go.sum
@ -19,8 +19,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU=
|
||||
github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k=
|
||||
github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE=
|
||||
github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho=
|
||||
github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw=
|
||||
github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI=
|
||||
github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE=
|
||||
@ -35,14 +35,14 @@ github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65E
|
||||
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
github.com/valyala/gorpc v0.0.0-20160519171614-908281bef774 h1:SUHFQHAaySqF0YHCmmm0EIFooFZpDPpi5KTom7YJ07c=
|
||||
github.com/valyala/gorpc v0.0.0-20160519171614-908281bef774/go.mod h1:8uNqM1i7pr0jO7gdvbNCgsSa8Ki2vMh7JCQxO9BlF90=
|
||||
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
|
||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
|
||||
golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
|
||||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY=
|
||||
golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg=
|
||||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
|
||||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg=
|
||||
golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI=
|
||||
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
|
||||
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
||||
@ -423,6 +423,12 @@ func extractTypes(file *ast.File, packageName string, structs map[string]*Struct
|
||||
Package: packageName,
|
||||
Type: getScalarFromAstIdent(typeSpecType),
|
||||
}
|
||||
case *ast.SelectorExpr:
|
||||
trace("SelectorExpr", obj.Name)
|
||||
structs[structName] = &Struct{
|
||||
Name: name,
|
||||
Package: packageName,
|
||||
}
|
||||
case *ast.ArrayType:
|
||||
arrayValue := &Value{}
|
||||
arrayValue.loadExpr(typeSpec.Type, fileImports)
|
||||
|
||||
@ -185,13 +185,7 @@ func renderTypescriptStruct(str *Struct, mappings config.TypeScriptMappings, sca
|
||||
}
|
||||
ts.app(" }")
|
||||
ts.nl()
|
||||
ts.app("export type " + str.Name + " = ")
|
||||
for i, field := range str.UnionFields {
|
||||
if i > 0 {
|
||||
ts.app(" | ")
|
||||
}
|
||||
field.Value.tsType(mappings, scalars, structs, ts, &JSONInfo{OmitEmpty: true})
|
||||
}
|
||||
ts.app("export type " + str.Name + " = typeof " + str.Name)
|
||||
ts.nl()
|
||||
default:
|
||||
return errors.New("could not resolve this union type")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user