robotgo icon indicating copy to clipboard operation
robotgo copied to clipboard

Compiled binary is too big

Open mardukbp opened this issue 3 years ago • 6 comments

  • 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.

mardukbp avatar Oct 18 '20 16:10 mardukbp

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.

wilon avatar Oct 20 '20 06:10 wilon

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.

mardukbp avatar Oct 20 '20 07:10 mardukbp

But in the desktop environment and embedded environment are not too big, and there have so many functions.

vcaesar avatar Oct 20 '20 14:10 vcaesar

In order to determine what takes up so much space: Why are my Go executable files so large?

mardukbp avatar Dec 25 '20 01:12 mardukbp

There splited the functionality to separate modules in version 1.x.

vcaesar avatar Nov 01 '22 18:11 vcaesar

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)
}

mardukbp avatar Nov 06 '22 18:11 mardukbp