diff --git a/pkg/generators/golang/clients_generator.go b/pkg/generators/golang/clients_generator.go index 94a190d..6600cbe 100644 --- a/pkg/generators/golang/clients_generator.go +++ b/pkg/generators/golang/clients_generator.go @@ -764,7 +764,7 @@ func (g *ClientsGenerator) generateRequestSource(method *concepts.Method) { g.buffer.Import("bytes", "") g.buffer.Import("context", "") g.buffer.Import("io", "") - g.buffer.Import("io/ioutil", "") + g.buffer.Import("os", "") g.buffer.Import("net/http", "") g.buffer.Import("net/url", "") g.buffer.Import(g.packages.ErrorsImport(), "") @@ -862,7 +862,7 @@ func (g *ClientsGenerator) generateRequestSource(method *concepts.Method) { URL: uri, Header: header, {{ if $requestBodyParameters }} - Body: ioutil.NopCloser(buffer), + Body: io.NopCloser(buffer), {{ end }} } if ctx != nil { @@ -1251,5 +1251,4 @@ var builtinGetters = map[string]interface{}{ "Status": nil, } -var builtinSetters = map[string]interface{}{ -} +var builtinSetters = map[string]interface{}{} diff --git a/pkg/generators/golang/openapi_generator.go b/pkg/generators/golang/openapi_generator.go index 95284ac..d3097c1 100644 --- a/pkg/generators/golang/openapi_generator.go +++ b/pkg/generators/golang/openapi_generator.go @@ -21,7 +21,6 @@ package golang import ( "fmt" - "io/ioutil" "os" "path/filepath" @@ -142,7 +141,7 @@ func (b *OpenAPIGeneratorBuilder) Build() (generator *OpenAPIGenerator, err erro // Run executes the code generator. func (g *OpenAPIGenerator) Run() error { // Create a temporary directory to write the OpenAPI JSON to, and remember to delete it: - jsonDir, err := ioutil.TempDir("", "openapi") + jsonDir, err := os.MkdirTemp("", "openapi") if err != nil { return g.reporter.Errorf("Can't create temporary OpenAPI directory: %v", err) } @@ -200,7 +199,7 @@ func (g *OpenAPIGenerator) generateSpec(version *concepts.Version, jsonDir strin // Read the JSON file that contains the previously generated OpenAPI specification: jsonFile := filepath.Join(jsonDir, g.names.FileName(version)) - jsonData, err := ioutil.ReadFile(jsonFile) + jsonData, err := os.ReadFile(jsonFile) if err != nil { return g.reporter.Errorf( "Can't read JSON file '%s' for version '%s': %v", diff --git a/pkg/language/main_test.go b/pkg/language/main_test.go index 6ab4631..9557c9b 100644 --- a/pkg/language/main_test.go +++ b/pkg/language/main_test.go @@ -17,7 +17,6 @@ limitations under the License. package language import ( - "io/ioutil" "os" "path/filepath" "testing" @@ -37,7 +36,7 @@ func TestLanguage(t *testing.T) { // given in the list of pairs. It then reads those model files and returns the resulting model. func MakeModel(pairs ...string) *concepts.Model { // Create a temporary directory for the model files: - root, err := ioutil.TempDir("", "model-*") + root, err := os.MkdirTemp("", "model-*") Expect(err).ToNot(HaveOccurred()) defer func() { err = os.RemoveAll(root) @@ -56,7 +55,7 @@ func MakeModel(pairs ...string) *concepts.Model { err = os.MkdirAll(dir, 0700) Expect(err).ToNot(HaveOccurred()) } - err = ioutil.WriteFile(path, []byte(data), 0600) + err = os.WriteFile(path, []byte(data), 0600) Expect(err).ToNot(HaveOccurred()) } diff --git a/pkg/language/model_parser.go b/pkg/language/model_parser.go index 625ebe6..a55553e 100644 --- a/pkg/language/model_parser.go +++ b/pkg/language/model_parser.go @@ -1273,9 +1273,7 @@ func (s *ClassDeclContext) Get_annotation() IAnnotationContext { return s._annot func (s *ClassDeclContext) GetName() IIdentifierContext { return s.name } -func (s *ClassDeclContext) Get_structMemberDecl() IStructMemberDeclContext { - return s._structMemberDecl -} +func (s *ClassDeclContext) Get_structMemberDecl() IStructMemberDeclContext { return s._structMemberDecl } func (s *ClassDeclContext) Set_annotation(v IAnnotationContext) { s._annotation = v } @@ -3675,9 +3673,7 @@ func (s *MethodParameterDeclContext) SetDflt(v ILiteralContext) { s.dflt = v } func (s *MethodParameterDeclContext) GetAnnotations() []IAnnotationContext { return s.annotations } -func (s *MethodParameterDeclContext) GetDirections() []IParameterDirectionContext { - return s.directions -} +func (s *MethodParameterDeclContext) GetDirections() []IParameterDirectionContext { return s.directions } func (s *MethodParameterDeclContext) SetAnnotations(v []IAnnotationContext) { s.annotations = v } @@ -5603,9 +5599,7 @@ func (s *AnnotationParametersContext) GetParameters() []IAnnotationParameterCont return s.parameters } -func (s *AnnotationParametersContext) SetParameters(v []IAnnotationParameterContext) { - s.parameters = v -} +func (s *AnnotationParametersContext) SetParameters(v []IAnnotationParameterContext) { s.parameters = v } func (s *AnnotationParametersContext) GetResult() map[string]interface{} { return s.result } diff --git a/pkg/language/reader.go b/pkg/language/reader.go index 2b7c9be..bc65209 100644 --- a/pkg/language/reader.go +++ b/pkg/language/reader.go @@ -184,7 +184,7 @@ func (r *Reader) loadModel(dir string) { } // List the services: - fileInfos, err := ioutil.ReadDir(dir) + fileInfos, err := os.ReadDir(dir) if err != nil { r.reporter.Errorf("Can't list model directory '%s': %v", dir, err) return @@ -231,7 +231,7 @@ func (r *Reader) loadService(dir string) { } // List the versions: - fileInfos, err := ioutil.ReadDir(dir) + fileInfos, err := os.ReadDir(dir) if err != nil { r.reporter.Errorf("Can't list service directory '%s': %v", dir, err) return