Skip to content

Commit

Permalink
Mark deprecated methods and print which method use instead (#74)
Browse files Browse the repository at this point in the history
* mark deprecated methods and print which method use instead

* dont use deprecated value as replacement function name
  • Loading branch information
LukasJenicek authored Oct 21, 2024
1 parent 8a2785a commit a5a85e3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
18 changes: 13 additions & 5 deletions _examples/golang-basics/example.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions _examples/golang-basics/example.ridl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ service ExampleService
@internal
- Status() => (status: bool)
- Version() => (version: Version)
# Get user endpoint
#
# gives you basic info about user
@deprecated
- GetUser(header: map<string,string>, userID: uint64) => (user: User)
- FindUser(s: SearchFilter) => (name: string, user: User)
- LogEvent(event: string)
2 changes: 1 addition & 1 deletion _examples/golang-basics/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

var (
client ExampleService
client ExampleServiceClient
)

// func TestMain()
Expand Down
4 changes: 2 additions & 2 deletions _examples/golang-imports/api.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions types.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ type {{$service.Name}} interface {
// {{ replaceAll $comment "\"" "'" }}
{{- end }}
{{- end }}
{{- $deprecated := index $method.Annotations "deprecated" -}}
{{- if $deprecated }}
// Deprecated:
{{- end }}
{{ if eq $method.StreamOutput true -}}
{{$method.Name}}(ctx context.Context{{range $_, $input := $method.Inputs}}, {{$input.Name}} {{template "field" dict "Name" $input.Name "Type" $input.Type "TypeMap" $typeMap "TypePrefix" $typePrefix "Optional" $input.Optional "TypeMeta" $input.Meta}}{{end}}, stream {{$method.Name}}StreamWriter) error
{{- else -}}
Expand Down Expand Up @@ -172,6 +176,10 @@ type {{$service.Name}}Client interface {
// {{ replaceAll $comment "\"" "'" }}
{{- end }}
{{- end }}
{{- $deprecated := index $method.Annotations "deprecated" -}}
{{- if $deprecated }}
// Deprecated:
{{- end }}
{{ if eq $method.StreamOutput true -}}
{{$method.Name}}(ctx context.Context{{range $_, $input := $method.Inputs}}, {{$input.Name}} {{template "field" dict "Name" $input.Name "Type" $input.Type "TypeMap" $typeMap "TypePrefix" $typePrefix "Optional" $input.Optional "TypeMeta" $input.Meta}}{{end}}) ({{$method.Name}}StreamReader, error)
{{- else -}}
Expand Down

0 comments on commit a5a85e3

Please sign in to comment.