Skip to content

Commit ac0debc

Browse files
committed
Lint fix
1 parent bddd1e1 commit ac0debc

File tree

4 files changed

+19
-21
lines changed

4 files changed

+19
-21
lines changed

browser_test/example_output.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"use strict";
22
/* Do not change, this code is generated from Golang structs */
3-
exports.__esModule = true;
3+
Object.defineProperty(exports, "__esModule", { value: true });
44
exports.Person = exports.PersonalInfo = exports.Address = void 0;
55
var Address = /** @class */ (function () {
66
function Address(source) {
7-
var _this = this;
87
if (source === void 0) { source = {}; }
8+
var _this = this;
99
//[Address:]
1010
/* Custom code here */
1111
this.getAddressString = function () {
@@ -22,8 +22,8 @@ var Address = /** @class */ (function () {
2222
exports.Address = Address;
2323
var PersonalInfo = /** @class */ (function () {
2424
function PersonalInfo(source) {
25-
var _this = this;
2625
if (source === void 0) { source = {}; }
26+
var _this = this;
2727
//[PersonalInfo:]
2828
this.getPersonalInfoString = function () {
2929
return "pet:" + _this.pet_name;
@@ -38,8 +38,8 @@ var PersonalInfo = /** @class */ (function () {
3838
exports.PersonalInfo = PersonalInfo;
3939
var Person = /** @class */ (function () {
4040
function Person(source) {
41-
var _this = this;
4241
if (source === void 0) { source = {}; }
42+
var _this = this;
4343
//[Person:]
4444
this.getInfo = function () {
4545
return "name:" + _this.name;

tscriptify/main.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ import (
66
"go/ast"
77
"go/parser"
88
"go/token"
9-
"io/ioutil"
109
"os"
1110
"os/exec"
1211
"strings"
1312
"text/template"
14-
"time"
1513
)
1614

1715
type arrayImports []string
@@ -96,12 +94,7 @@ func main() {
9694

9795
t := template.Must(template.New("").Parse(TEMPLATE))
9896

99-
filename, err := ioutil.TempDir(os.TempDir(), "")
100-
handleErr(err)
101-
102-
filename = fmt.Sprintf("%s/typescriptify_%d.go", filename, time.Now().Nanosecond())
103-
104-
f, err := os.Create(filename)
97+
f, err := os.CreateTemp(os.TempDir(), "typescriptify_*.go")
10598
handleErr(err)
10699
defer f.Close()
107100

@@ -121,12 +114,12 @@ func main() {
121114
handleErr(err)
122115

123116
if p.Verbose {
124-
byts, err := ioutil.ReadFile(filename)
117+
byts, err := os.ReadFile(f.Name())
125118
handleErr(err)
126-
fmt.Printf("\nCompiling generated code (%s):\n%s\n----------------------------------------------------------------------------------------------------\n", filename, string(byts))
119+
fmt.Printf("\nCompiling generated code (%s):\n%s\n----------------------------------------------------------------------------------------------------\n", f.Name(), string(byts))
127120
}
128121

129-
cmd := exec.Command("go", "run", filename)
122+
cmd := exec.Command("go", "run", f.Name())
130123
fmt.Println(strings.Join(cmd.Args, " "))
131124
output, err := cmd.CombinedOutput()
132125
if err != nil {

typescriptify/typescriptify.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package typescriptify
22

33
import (
44
"fmt"
5-
"io/ioutil"
5+
"io"
66
"os"
77
"path"
88
"reflect"
@@ -365,7 +365,7 @@ func loadCustomCode(fileName string) (map[string]string, error) {
365365
}
366366
defer f.Close()
367367

368-
bytes, err := ioutil.ReadAll(f)
368+
bytes, err := io.ReadAll(f)
369369
if err != nil {
370370
return result, err
371371
}
@@ -401,7 +401,7 @@ func (t TypeScriptify) backup(fileName string) error {
401401
}
402402
defer fileIn.Close()
403403

404-
bytes, err := ioutil.ReadAll(fileIn)
404+
bytes, err := io.ReadAll(fileIn)
405405
if err != nil {
406406
return err
407407
}
@@ -411,7 +411,7 @@ func (t TypeScriptify) backup(fileName string) error {
411411
backupFn = path.Join(t.BackupDir, backupFn)
412412
}
413413

414-
return ioutil.WriteFile(backupFn, bytes, os.FileMode(0700))
414+
return os.WriteFile(backupFn, bytes, os.FileMode(0700))
415415
}
416416

417417
func (t TypeScriptify) ConvertToFile(fileName string) error {

typescriptify/typescriptify_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package typescriptify
33
import (
44
"encoding/json"
55
"fmt"
6-
"io/ioutil"
76
"os"
87
"os/exec"
98
"reflect"
@@ -303,10 +302,14 @@ func testConverter(t *testing.T, converter *TypeScriptify, strictMode bool, desi
303302
}
304303

305304
func testTypescriptExpression(t *testing.T, strictMode bool, baseScript string, tsExpressionAndDesiredResults []string) {
306-
f, err := ioutil.TempFile(os.TempDir(), "*.ts")
305+
f, err := os.CreateTemp(os.TempDir(), "*.ts")
307306
assert.Nil(t, err)
308307
assert.NotNil(t, f)
309308

309+
if t.Failed() {
310+
t.FailNow()
311+
}
312+
310313
_, _ = f.WriteString(baseScript)
311314
_, _ = f.WriteString("\n")
312315
for n, expr := range tsExpressionAndDesiredResults {
@@ -977,6 +980,8 @@ func TestFieldNamesWithoutJSONAnnotation(t *testing.T) {
977980
PublicField string
978981
privateField string
979982
}
983+
var tmp WithoutAnnotation
984+
tmp.privateField = ""
980985

981986
converter := New().Add(WithoutAnnotation{})
982987
desiredResult := `

0 commit comments

Comments
 (0)