robotgo
robotgo copied to clipboard
Compiled binary is too big
- Robotgo version (or commit ref): fdaa440f26
- Go version: 1.15.3
- Gcc version: 9.2.0
- Operating system and bit: Windows 10 64 bit
- Resolution: 1920x1080
- Can you reproduce the bug at Examples:
- [ ] Yes (provide example code)
- [ ] No
- [X ] Not relevant
- Provide example code:
package main
import "github.com/go-vgo/robotgo"
func main() {
robotgo.TypeStr("Hello World!", 1.0)
}
- Log gist:
Description
Compiling the above code with go build -ldflags "-s -w"
produces a 4.1 MB binary. The corresponding code using enigo in Rust produces a 244 kB binary. Since both are statically linked, I think that the comparison is fair. For reference, a calculator written in Go and Tk weighs 2.4 MB.
You can try upx. The bin change 5.8M to 2.1M on my test.
Another way to is split package robotgo. This is unnecessary I think.
Such as split github.com/go-vgo/robotgo
to github.com/go-vgo/robotgomouse
,github.com/go-vgo/robotgokey
,github.com/go-vgo/robotgotype
..., only use one of it can reduce binary volume.
To be fair enigo only corresponds to robotgokey. I think it is a good idea to split the functionality in separate modules. That way people can use only what they need. It makes no sense to link to libpng or zlib, when you only need to simulate a key press.
Of course I could extract the part of RobotGo that I need for my program. But it takes time and it defeats the purpose of a software library. It is supposed to be integrated in a larger project, not be stripped like a chicken wing.
RobotGo is a great project with lots of potential. I think it deserves some investment to increase its usefulness.
But in the desktop environment and embedded environment are not too big, and there have so many functions.
In order to determine what takes up so much space: Why are my Go executable files so large?
There splited the functionality to separate modules in version 1.x.
Thanks. I see that the are now separate packages. But it seems to me that most do not export anything yet. For example key/key.go is empty. I would expect the following code to work:
package main
import "github.com/go-vgo/robotgo/key"
func main() {
key.TypeStr("Hello World!", 1.0)
}