Skip to content

Commit 7f1a0af

Browse files
committed
apply gofumpt to all code
1 parent b83b0ff commit 7f1a0af

File tree

6 files changed

+137
-73
lines changed

6 files changed

+137
-73
lines changed

app.go

+12-9
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ func (e *AppError) Error() string {
5757
type UpdateKeyField interface {
5858
JSONValue() interface{}
5959
}
60+
6061
type UpdateKey struct {
6162
FieldCode string
6263
Field UpdateKeyField
@@ -181,6 +182,7 @@ func (app *App) createUrl(api string, query string) url.URL {
181182
}
182183
return resultUrl
183184
}
185+
184186
func (app *App) setAuth(request *http.Request) {
185187
if app.basicAuth {
186188
request.SetBasicAuth(app.basicAuthUser, app.basicAuthPassword)
@@ -196,7 +198,7 @@ func (app *App) setAuth(request *http.Request) {
196198
}
197199
}
198200

199-
//NewRequest create a request connect to kintone api.
201+
// NewRequest create a request connect to kintone api.
200202
func (app *App) NewRequest(method, url string, body io.Reader) (*http.Request, error) {
201203
bodyData := io.Reader(nil)
202204
if body != nil {
@@ -321,18 +323,18 @@ func parseResponse(resp *http.Response) ([]byte, error) {
321323
}
322324
}
323325

324-
//Get other than the Errors property
326+
// Get other than the Errors property
325327
var ae AppError
326328
json.Unmarshal(body, &ae)
327329
ae.HttpStatus = resp.Status
328330
ae.HttpStatusCode = resp.StatusCode
329331

330-
//Get the Errors property
332+
// Get the Errors property
331333
var errors interface{}
332334
json.Unmarshal(body, &errors)
333335
msg := errors.(map[string]interface{})
334336
v, ok := msg["errors"]
335-
//If the Errors property exists
337+
// If the Errors property exists
336338
if ok {
337339
result, err := json.Marshal(v)
338340
if err != nil {
@@ -1015,7 +1017,8 @@ func (fi *FieldInfo) UnmarshalJSON(data []byte) error {
10151017
t.MaxValue, t.MinValue, t.MaxLength, t.MinLength,
10161018
t.Default, t.DefaultTime, t.Options, t.Expression,
10171019
(t.Separator == "true"),
1018-
t.Medium, t.Format, t.Fields}
1020+
t.Medium, t.Format, t.Fields,
1021+
}
10191022
return nil
10201023
}
10211024

@@ -1049,14 +1052,14 @@ func (app *App) Fields() (map[string]*FieldInfo, error) {
10491052
}
10501053

10511054
ret := make(map[string]*FieldInfo)
1052-
for i, _ := range t.Properties {
1055+
for i := range t.Properties {
10531056
fi := &(t.Properties[i])
10541057
ret[fi.Code] = fi
10551058
}
10561059
return ret, nil
10571060
}
10581061

1059-
//CreateCursor return the meta data of the Cursor in this application
1062+
// CreateCursor return the meta data of the Cursor in this application
10601063
func (app *App) CreateCursor(fields []string, query string, size uint64) (*Cursor, error) {
10611064
type cursor struct {
10621065
App uint64 `json:"app"`
@@ -1112,8 +1115,8 @@ func (app *App) DeleteCursor(id string) error {
11121115
return nil
11131116
}
11141117

1115-
//Using Cursor Id to get all records
1116-
//GetRecordsByCursor return the meta data of the Record in this application
1118+
// Using Cursor Id to get all records
1119+
// GetRecordsByCursor return the meta data of the Record in this application
11171120
func (app *App) GetRecordsByCursor(id string) (*GetRecordsCursorResponse, error) {
11181121
url := app.createUrl("records/cursor", "id="+id)
11191122
request, err := app.NewRequest("GET", url.String(), nil)

app_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ const (
3939
func createServerTest(mux *http.ServeMux) (*httptest.Server, error) {
4040
ts := httptest.NewUnstartedServer(mux)
4141
listen, err := net.Listen("tcp", KINTONE_DOMAIN)
42-
4342
if err != nil {
4443
return nil, err
4544
}
@@ -207,6 +206,7 @@ func newApp() *App {
207206
AppId: KINTONE_APP_ID,
208207
}
209208
}
209+
210210
func newAppWithGuest() *App {
211211
return &App{
212212
Domain: KINTONE_DOMAIN,
@@ -216,6 +216,7 @@ func newAppWithGuest() *App {
216216
GuestSpaceId: KINTONE_GUEST_SPACE_ID,
217217
}
218218
}
219+
219220
func newAppWithToken() *App {
220221
return &App{
221222
AppId: KINTONE_APP_ID,
@@ -259,6 +260,7 @@ func TestAddRecord(t *testing.T) {
259260
t.Log(ids)
260261
}
261262
}
263+
262264
func TestGetRecord(t *testing.T) {
263265
testData := GetTestDataGetRecord()
264266
testDataRecords := GetTestDataGetRecords()
@@ -298,8 +300,8 @@ func TestGetRecord(t *testing.T) {
298300
} else {
299301
t.Log(len(recs))
300302
}
301-
302303
}
304+
303305
func TestUpdateRecord(t *testing.T) {
304306
testData := GetTestDataGetRecord()
305307
testDataRecords := GetTestDataGetRecords()
@@ -359,7 +361,6 @@ func TestGetRecordsByCursor(t *testing.T) {
359361
if err != nil {
360362
t.Errorf("TestGetCursor is failed: %v", err)
361363
}
362-
363364
}
364365

365366
func TestDeleteCursor(t *testing.T) {

app_test_json.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ func GetTestDataDeleteRecords() *TestData {
8888
output: `{}`,
8989
}
9090
}
91+
9192
func GetTestDataGetRecord() *TestData {
9293
return &TestData{
9394
input: []interface{}{1, true},
@@ -289,6 +290,7 @@ func GetDataTestDeleteRecordComment() *TestData {
289290
output: `{}`,
290291
}
291292
}
293+
292294
func GetTestDataAddRecord() *TestData {
293295
return &TestData{
294296
output: `{
@@ -324,6 +326,7 @@ func GetDataTestAddRecord() *TestData {
324326
}`,
325327
}
326328
}
329+
327330
func getDataTestCreateCursor() *TestData {
328331
return &TestData{
329332
output: `
@@ -332,10 +335,9 @@ func getDataTestCreateCursor() *TestData {
332335
"totalCount": 123456
333336
}`,
334337
}
335-
336338
}
337-
func GetDataTestGetRecordsByCursor() *TestData {
338339

340+
func GetDataTestGetRecordsByCursor() *TestData {
339341
return &TestData{
340342
input: []interface{}{"9a9716fe-1394-4677-a1c7-2199a5d28215"},
341343
output: `
@@ -384,6 +386,7 @@ func GetTestDataAddRecordComment() *TestData {
384386
output: `{"id": "4"}`,
385387
}
386388
}
389+
387390
func GetTestDataUpdateRecordByKey() *TestData {
388391
return &TestData{
389392
input: []interface{}{2, "key", true},

cursor.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,26 @@ import (
44
"encoding/json"
55
)
66

7-
//Object Cursor structure
7+
// Object Cursor structure
88
type Cursor struct {
99
Id string `json:"id"`
1010
TotalCount string `json:"totalCount"`
1111
}
12+
1213
type GetRecordsCursorResponse struct {
1314
Records []*Record `json:"records"`
1415
Next bool `json:"next"`
1516
}
1617

17-
//decodeCursor decodes JSON response for cursor api
18+
// decodeCursor decodes JSON response for cursor api
1819
func decodeCursor(b []byte) (c *Cursor, err error) {
1920
err = json.Unmarshal(b, &c)
2021
if err != nil {
2122
return nil, err
2223
}
2324
return c, nil
2425
}
26+
2527
func DecodeGetRecordsCursorResponse(b []byte) (rc *GetRecordsCursorResponse, err error) {
2628
var t struct {
2729
Next bool `json:"next"`

0 commit comments

Comments
 (0)