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

Handle empty comment lines #2

Merged
merged 1 commit into from
Mar 15, 2020
Merged

Handle empty comment lines #2

merged 1 commit into from
Mar 15, 2020

Conversation

gkze
Copy link
Contributor

@gkze gkze commented Mar 15, 2020

Handles cases where the line is a single octothorp (#). In the case below:

#
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost
255.255.255.255	broadcasthost
::1             localhost
# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section

When hostctl list is run, it panics:

Using hosts file: /etc/hosts
panic: runtime error: index out of range [1] with length 1

goroutine 1 [running]:
github.com/guumaster/hostctl/pkg/host.IsHostLine(0x138b423, 0x1, 0x6)
	/Users/gkontridze/Development/go/pkg/mod/github.com/guumaster/[email protected]/pkg/host/host_file.go:95 +0xdc
github.com/guumaster/hostctl/pkg/host.appendProfile(0x1209322, 0x7, 0xc000156000, 0xc000126e00, 0xd, 0x10)
	/Users/gkontridze/Development/go/pkg/mod/github.com/guumaster/[email protected]/pkg/host/list.go:66 +0x95
github.com/guumaster/hostctl/pkg/host.ListProfiles(0x1209bb9, 0xa, 0xc00013bd78, 0x1209bb9, 0xa)
	/Users/gkontridze/Development/go/pkg/mod/github.com/guumaster/[email protected]/pkg/host/list.go:34 +0x260
github.com/guumaster/hostctl/cmd.glob..func9(0x13a0ca0, 0x13cdf38, 0x0, 0x0, 0x0, 0x0)
	/Users/gkontridze/Development/go/pkg/mod/github.com/guumaster/[email protected]/cmd/list.go:24 +0xd5
github.com/spf13/cobra.(*Command).execute(0x13a0ca0, 0x13cdf38, 0x0, 0x0, 0x13a0ca0, 0x13cdf38)
	/Users/gkontridze/Development/go/pkg/mod/github.com/spf13/[email protected]/command.go:840 +0x453
github.com/spf13/cobra.(*Command).ExecuteC(0x13a1480, 0x0, 0x0, 0x0)
	/Users/gkontridze/Development/go/pkg/mod/github.com/spf13/[email protected]/command.go:945 +0x317
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/gkontridze/Development/go/pkg/mod/github.com/spf13/[email protected]/command.go:885
github.com/guumaster/hostctl/cmd.Execute()
	/Users/gkontridze/Development/go/pkg/mod/github.com/guumaster/[email protected]/cmd/root.go:35 +0x2d
main.main()
	/Users/gkontridze/Development/go/pkg/mod/github.com/guumaster/[email protected]/main.go:10 +0x20

@guumaster guumaster merged commit 24a6c43 into guumaster:master Mar 15, 2020
@guumaster
Copy link
Owner

Thanks for your contribution! I'll tests and release new version soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants