Skip to content

Commit 7762457

Browse files
committed
chore: lint
1 parent faabd1b commit 7762457

File tree

4 files changed

+76
-76
lines changed

4 files changed

+76
-76
lines changed

Diff for: typesense/api/types.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ type ImportDocumentResponse struct {
77
}
88

99
type StemmingDictionaryWord struct {
10-
Root string `json:"root"`
11-
Word string `json:"word"`
10+
Root string `json:"root"`
11+
Word string `json:"word"`
1212
}

Diff for: typesense/stemming.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
package typesense
22

33
type StemmingInterface interface {
4-
Dictionaries() StemmingDictionariesInterface
5-
Dictionary(dictionaryId string) StemmingDictionaryInterface
4+
Dictionaries() StemmingDictionariesInterface
5+
Dictionary(dictionaryId string) StemmingDictionaryInterface
66
}
77

88
type stemming struct {
9-
apiClient APIClientInterface
9+
apiClient APIClientInterface
1010
}
1111

1212
func (s *stemming) Dictionaries() StemmingDictionariesInterface {
13-
return &stemmingDictionaries{apiClient: s.apiClient}
13+
return &stemmingDictionaries{apiClient: s.apiClient}
1414
}
1515

1616
func (s *stemming) Dictionary(dictionaryId string) StemmingDictionaryInterface {
17-
return &stemmingDictionary{apiClient: s.apiClient, dictionaryId: dictionaryId}
18-
}
17+
return &stemmingDictionary{apiClient: s.apiClient, dictionaryId: dictionaryId}
18+
}

Diff for: typesense/stemming_dictionaries.go

+56-56
Original file line numberDiff line numberDiff line change
@@ -11,74 +11,74 @@ import (
1111
)
1212

1313
type StemmingDictionariesInterface interface {
14-
Upsert(ctx context.Context, dictionaryId string, wordRootCombinations []api.StemmingDictionaryWord) ([]*api.StemmingDictionaryWord, error)
15-
UpsertJsonl(ctx context.Context, dictionaryId string, body io.Reader) (io.ReadCloser, error)
16-
Retrieve(ctx context.Context) (*api.ListStemmingDictionariesResponse, error)
14+
Upsert(ctx context.Context, dictionaryId string, wordRootCombinations []api.StemmingDictionaryWord) ([]*api.StemmingDictionaryWord, error)
15+
UpsertJsonl(ctx context.Context, dictionaryId string, body io.Reader) (io.ReadCloser, error)
16+
Retrieve(ctx context.Context) (*api.ListStemmingDictionariesResponse, error)
1717
}
1818

1919
type stemmingDictionaries struct {
20-
apiClient APIClientInterface
20+
apiClient APIClientInterface
2121
}
2222

2323
func (s *stemmingDictionaries) Upsert(ctx context.Context, dictionaryId string, wordRootCombinations []api.StemmingDictionaryWord) ([]*api.StemmingDictionaryWord, error) {
24-
var buf bytes.Buffer
25-
jsonEncoder := json.NewEncoder(&buf)
26-
for _, combo := range wordRootCombinations {
27-
if err := jsonEncoder.Encode(combo); err != nil {
28-
return nil, err
29-
}
30-
}
24+
var buf bytes.Buffer
25+
jsonEncoder := json.NewEncoder(&buf)
26+
for _, combo := range wordRootCombinations {
27+
if err := jsonEncoder.Encode(combo); err != nil {
28+
return nil, err
29+
}
30+
}
3131

32-
response, err := s.UpsertJsonl(ctx, dictionaryId, &buf)
33-
if err != nil {
34-
return nil, err
35-
}
32+
response, err := s.UpsertJsonl(ctx, dictionaryId, &buf)
33+
if err != nil {
34+
return nil, err
35+
}
3636

37-
var result []*api.StemmingDictionaryWord
38-
jsonDecoder := json.NewDecoder(response)
39-
for jsonDecoder.More() {
40-
var docResult *api.StemmingDictionaryWord
41-
if err := jsonDecoder.Decode(&docResult); err != nil {
42-
return result, err
43-
}
44-
result = append(result, docResult)
45-
}
37+
var result []*api.StemmingDictionaryWord
38+
jsonDecoder := json.NewDecoder(response)
39+
for jsonDecoder.More() {
40+
var docResult *api.StemmingDictionaryWord
41+
if err := jsonDecoder.Decode(&docResult); err != nil {
42+
return result, err
43+
}
44+
result = append(result, docResult)
45+
}
4646

47-
return result, nil
47+
return result, nil
4848
}
4949

5050
func (s *stemmingDictionaries) UpsertJsonl(ctx context.Context, dictionaryId string, body io.Reader) (io.ReadCloser, error) {
51-
params := &api.ImportStemmingDictionaryParams{
52-
Id: dictionaryId,
53-
}
54-
55-
response, err := s.apiClient.ImportStemmingDictionaryWithBody(ctx,
56-
params, "application/octet-stream", body)
57-
if err != nil {
58-
return nil, err
59-
}
60-
if response.StatusCode != http.StatusOK {
61-
defer response.Body.Close()
62-
body, _ := io.ReadAll(response.Body)
63-
return nil, &HTTPError{Status: response.StatusCode, Body: body}
64-
}
65-
return response.Body, nil
51+
params := &api.ImportStemmingDictionaryParams{
52+
Id: dictionaryId,
53+
}
54+
55+
response, err := s.apiClient.ImportStemmingDictionaryWithBody(ctx,
56+
params, "application/octet-stream", body)
57+
if err != nil {
58+
return nil, err
59+
}
60+
if response.StatusCode != http.StatusOK {
61+
defer response.Body.Close()
62+
body, _ := io.ReadAll(response.Body)
63+
return nil, &HTTPError{Status: response.StatusCode, Body: body}
64+
}
65+
return response.Body, nil
6666
}
6767

6868
func (s *stemmingDictionaries) Retrieve(ctx context.Context) (*api.ListStemmingDictionariesResponse, error) {
69-
response, err := s.apiClient.ListStemmingDictionariesWithResponse(ctx)
70-
if err != nil {
71-
return nil, err
72-
}
73-
if response.JSON200 == nil {
74-
emptySlice := make([]string, 0)
75-
return &api.ListStemmingDictionariesResponse{
76-
JSON200: &struct {
77-
Dictionaries *[]string `json:"dictionaries,omitempty"`
78-
}{
79-
Dictionaries: &emptySlice,
80-
},
81-
}, nil
82-
}
83-
return response, nil
84-
}
69+
response, err := s.apiClient.ListStemmingDictionariesWithResponse(ctx)
70+
if err != nil {
71+
return nil, err
72+
}
73+
if response.JSON200 == nil {
74+
emptySlice := make([]string, 0)
75+
return &api.ListStemmingDictionariesResponse{
76+
JSON200: &struct {
77+
Dictionaries *[]string `json:"dictionaries,omitempty"`
78+
}{
79+
Dictionaries: &emptySlice,
80+
},
81+
}, nil
82+
}
83+
return response, nil
84+
}

Diff for: typesense/stemming_dictionary.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ import (
77
)
88

99
type StemmingDictionaryInterface interface {
10-
Retrieve(ctx context.Context) (*api.StemmingDictionary, error)
10+
Retrieve(ctx context.Context) (*api.StemmingDictionary, error)
1111
}
1212

1313
type stemmingDictionary struct {
14-
apiClient APIClientInterface
15-
dictionaryId string
14+
apiClient APIClientInterface
15+
dictionaryId string
1616
}
1717

1818
func (s *stemmingDictionary) Retrieve(ctx context.Context) (*api.StemmingDictionary, error) {
19-
response, err := s.apiClient.GetStemmingDictionaryWithResponse(ctx, s.dictionaryId)
20-
if err != nil {
21-
return nil, err
22-
}
23-
if response.JSON200 == nil {
24-
return nil, &HTTPError{Status: response.StatusCode(), Body: response.Body}
25-
}
26-
return response.JSON200, nil
27-
}
19+
response, err := s.apiClient.GetStemmingDictionaryWithResponse(ctx, s.dictionaryId)
20+
if err != nil {
21+
return nil, err
22+
}
23+
if response.JSON200 == nil {
24+
return nil, &HTTPError{Status: response.StatusCode(), Body: response.Body}
25+
}
26+
return response.JSON200, nil
27+
}

0 commit comments

Comments
 (0)