Add build tag to omit the x/crypto/ssh dependency#645
Add build tag to omit the x/crypto/ssh dependency#645espadolini wants to merge 1 commit intopkg:masterfrom
Conversation
puellanivis
left a comment
There was a problem hiding this comment.
I mean… this doesn’t remove it from the go.mod so it’s going to get pulled in anyways?
Dead-code analysis should let this be removed anyways?
If someone has serious concerns about 900 KiB of binary size, then they’ll probably want to vendor/fork and do significantly more manual dead code removal than add an esoteric, and poorly discoverable build flag option?
DCE can't change the semantics of the code, and there's enough init time code in
Adding a build tag seemed less invasive than moving all code except for I'd happily take that as an option tho, it would work way better.
DCE seems to work quite well for sftp - at least in the case of a full featured server such as the one in server_standalone, I'm not really seeing any client code and 900KiB is not a lot in absolute terms but it's a third of the binary, in the case of server_standalone, so it's just a little unfortunate, that's all. |
The only use of
golang.org/x/crypto/ssh(and, transitively, of any package incrypto/...) is in theNewClientfunction, which is a small wrapper around running a subsystem request with anssh.Clientto 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 ofserver_standalone(darwin arm64, go 1.26.1) goes from 2.9 to 2.0 MiB, which is (relatively) significant.This PR moves
NewClientto a new file which is omitted from the build if a newpkg_sftp.omit_sshbuild tag is set during the build, so users of the library that don't usex/crypto/sshcan omit that dependency.