Skip to content

Commit

Permalink
Merge pull request #721 from panapol-p/fix/golang-ioutils
Browse files Browse the repository at this point in the history
fix(golang)/use io instead of io/ioutil
  • Loading branch information
VShingala authored Jul 29, 2024
2 parents c9c7244 + 21eb0b8 commit 21ab0a0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions codegens/golang/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ self = module.exports = {
// Setting isFile as false for further calls to this function
isFile = false;
}
codeSnippet += `${indent}"net/http"\n${indent}"io/ioutil"\n)\n\n`;
codeSnippet += `${indent}"net/http"\n${indent}"io"\n)\n\n`;

codeSnippet += `func main() {\n\n${indent}url := "${getUrlStringfromUrlObject(request.url)}"\n`;
codeSnippet += `${indent}method := "${request.method}"\n\n`;
Expand Down Expand Up @@ -297,7 +297,7 @@ self = module.exports = {
responseSnippet = `${indent}res, err := client.Do(req)\n`;
responseSnippet += `${indent}if err != nil {\n${indent.repeat(2)}fmt.Println(err)\n`;
responseSnippet += `${indent.repeat(2)}return\n${indent}}\n`;
responseSnippet += `${indent}defer res.Body.Close()\n\n${indent}body, err := ioutil.ReadAll(res.Body)\n`;
responseSnippet += `${indent}defer res.Body.Close()\n\n${indent}body, err := io.ReadAll(res.Body)\n`;
responseSnippet += `${indent}if err != nil {\n${indent.repeat(2)}fmt.Println(err)\n`;
responseSnippet += `${indent.repeat(2)}return\n${indent}}\n`;
responseSnippet += `${indent}fmt.Println(string(body))\n}`;
Expand Down

0 comments on commit 21ab0a0

Please sign in to comment.