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

config: add DecodeBytes to directly read a byte array #45

Merged
merged 1 commit into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Carlos A Becker <caarlos0@gmail.com>
Dustin Spicuzza <dustin@virtualroadside.com>
Eugene Terentev <eugene@terentev.net>
Kevin Burke <kevin@burke.dev>
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ race-test: lint
$(BUMP_VERSION):
go get -u github.com/kevinburke/bump_version

$(WRITE_MAILMAP):
go get -u github.com/kevinburke/write_mailmap

release: test | $(BUMP_VERSION)
$(BUMP_VERSION) minor config.go

Expand Down
6 changes: 6 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ func Decode(r io.Reader) (*Config, error) {
return decodeBytes(b, false, 0)
}

// DecodeBytes reads b into a Config, or returns an error if r could not be
// parsed as an SSH config file.
func DecodeBytes(b []byte) (*Config, error) {
return decodeBytes(b, false, 0)
}

func decodeBytes(b []byte, system bool, depth uint8) (c *Config, err error) {
defer func() {
if r := recover(); r != nil {
Expand Down