Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime error #79

Closed
Zaffy opened this issue Mar 8, 2022 · 1 comment
Closed

runtime error #79

Zaffy opened this issue Mar 8, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Zaffy
Copy link

Zaffy commented Mar 8, 2022

Describe the bug

A line in hosts file causes runtime error:

panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/guumaster/hostctl/pkg/parser.parseToDefault({0xc00042213c, 0x9, 0xec4}, {0x0, 0x55c8d424ac5b})
        github.com/guumaster/hostctl/pkg/parser/parser.go:116 +0x1dc
github.com/guumaster/hostctl/pkg/parser.Parse({0x55c8d4861aa0, 0xc00019c4b0})
        github.com/guumaster/hostctl/pkg/parser/parser.go:67 +0x48a
github.com/guumaster/hostctl/pkg/file.NewWithFs({0x55c8d45681f5, 0x55c8d4567e4c}, {0x55c8d48724f8, 0x55c8d4b2da28})
        github.com/guumaster/hostctl/pkg/file/file.go:43 +0x10a
github.com/guumaster/hostctl/pkg/file.NewFile(...)
        github.com/guumaster/hostctl/pkg/file/file.go:26
github.com/guumaster/hostctl/cmd/hostctl/actions.newListCmd.func1(0xc00041e580, {0x55c8d4b2da28, 0x0, 0x0})
        github.com/guumaster/hostctl/cmd/hostctl/actions/list.go:24 +0x5f
github.com/spf13/cobra.(*Command).execute(0xc00041e580, {0x55c8d4b2da28, 0x0, 0x0})
        github.com/spf13/[email protected]/command.go:842 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0xc0001c6dc0)
        github.com/spf13/[email protected]/command.go:950 +0x3ad
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/[email protected]/command.go:887
main.main()
        ./main.go:19 +0x76

To Reproduce
Steps to reproduce the behavior:

echo '# 1.1.1.1' > /tmp/hosts
hostctl --host-file /tmp/hosts list

Expected behavior
A clear and concise description of what you expected to happen.

The line should be treated as comment and not crash.

System (please complete the following information):

  • archlinux
  • aur / hostctl version 1.1.1
@Zaffy Zaffy added the bug Something isn't working label Mar 8, 2022
@guumaster
Copy link
Owner

fixed in v1.1.3 Thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants