Skip to content

Commit 65508c6

Browse files
committed
Remove useless interface{}
1 parent 7526cbc commit 65508c6

File tree

7 files changed

+10
-10
lines changed

7 files changed

+10
-10
lines changed

shell/bash.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ func newBashParser() *bashParser {
2121
return bashParser
2222
}
2323

24-
func (bashParser *bashParser) parse(content []byte) (interface{}, error) {
24+
func (bashParser *bashParser) parse(content []byte) ([]Function, error) {
2525
return bashParser.analyzer(bashParser.tokenizer.ParseBytes(content))
2626
}
2727

28-
func (bashParser *bashParser) analyzer(stream *tokenizer.Stream) (interface{}, error) {
28+
func (bashParser *bashParser) analyzer(stream *tokenizer.Stream) ([]Function, error) {
2929
functions := []Function{}
3030
comments := map[int][]*tokenizer.Token{}
3131
for {

shell/bash_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ another_little_func () {}
3434
3535
function_test () {}
3636
`))
37-
functions := data.([]Function)
37+
functions := data
3838
assert.NoError(t, err)
3939
assert.Len(t, functions, 7)
4040
assert.Equal(t, []Function{

shell/fish.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func newFishParser() *fishParser {
1111
return &fishParser{}
1212
}
1313

14-
func (fishParser *fishParser) parse(content []byte) (interface{}, error) {
14+
func (fishParser *fishParser) parse(content []byte) ([]Function, error) {
1515
fs := []Function{}
1616
r := regexp.MustCompile(`function\s+(?P<function>[^ |;|\n]+)(?:\s+--?d(?:escription)?\s+(?:"|')(?P<definition>[^(?:'|")]+)(?:"|'))?`).FindAllStringSubmatch(string(content), -1)
1717
for _, l := range r {

shell/fish_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function f5 -d "f5 description comment";echo e; end
2727
2828
function f6;echo e; end
2929
`))
30-
functions := data.([]Function)
30+
functions := data
3131
assert.NoError(t, err)
3232
assert.Len(t, functions, 6)
3333
assert.Equal(t, []Function{

shell/parser.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type Function struct {
3333
}
3434

3535
func Parse(shell string, content []byte) ([]Function, error) {
36-
var data interface{}
36+
var data []Function
3737
var err error
3838
switch shell {
3939
case string(zsh):
@@ -56,7 +56,7 @@ func Parse(shell string, content []byte) ([]Function, error) {
5656
}
5757
}
5858
fs := []Function{}
59-
for _, f := range data.([]Function) {
59+
for _, f := range data {
6060
f.Description = strings.ReplaceAll(f.Description, "function ", "function")
6161
fs = append(fs, f)
6262
}

shell/zsh.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ func newZshParser() *zshParser {
2121
return zshParser
2222
}
2323

24-
func (zshParser *zshParser) parse(content []byte) (interface{}, error) {
24+
func (zshParser *zshParser) parse(content []byte) ([]Function, error) {
2525
return zshParser.analyzer(zshParser.tokenizer.ParseBytes(content))
2626
}
2727

28-
func (zshParser *zshParser) analyzer(stream *tokenizer.Stream) (interface{}, error) {
28+
func (zshParser *zshParser) analyzer(stream *tokenizer.Stream) ([]Function, error) {
2929
functions := []Function{}
3030
comments := map[int][]*tokenizer.Token{}
3131
for {

shell/zsh_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ another_little_func () {}
3838
3939
function_test () {}
4040
`))
41-
functions := data.([]Function)
41+
functions := data
4242
assert.NoError(t, err)
4343
assert.Len(t, functions, 9)
4444
assert.Equal(t, []Function{

0 commit comments

Comments
 (0)