Skip to content

Add build tag to omit the x/crypto/ssh dependency#645

Open
espadolini wants to merge 1 commit intopkg:masterfrom
espadolini:omit-ssh-tag
Open

Add build tag to omit the x/crypto/ssh dependency#645
espadolini wants to merge 1 commit intopkg:masterfrom
espadolini:omit-ssh-tag

Conversation

@espadolini
Copy link
Copy Markdown

The only use of golang.org/x/crypto/ssh (and, transitively, of any package in crypto/...) is in the NewClient function, which is a small wrapper around running a subsystem request with an ssh.Client to then run a sftp client on the channel.

For binaries that don't otherwise depend on x/crypto/ssh (for example utility binaries that only do sftp through stdio) this can be a somewhat significant chunk of binary size; for example a stripped cgoless build of server_standalone (darwin arm64, go 1.26.1) goes from 2.9 to 2.0 MiB, which is (relatively) significant.

This PR moves NewClient to a new file which is omitted from the build if a new pkg_sftp.omit_ssh build tag is set during the build, so users of the library that don't use x/crypto/ssh can omit that dependency.

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.

1 participant