How to disable all go compiler build output compressions?

129 views
Skip to first unread message

Aurora

unread,
Dec 15, 2022, 1:58:33 PM12/15/22
to golang-nuts
I've embedded an empty 100MB file in my Go code, for some testing purposes.
When I run 'go build', the binary output would be something around 20MB.

I want the output binary to be more than 100MB, its real size.

How's this compression being applied to the binary?
How to disable all such optimisations?

Kurtis Rader

unread,
Dec 15, 2022, 4:45:48 PM12/15/22
to Aurora, golang-nuts
Please clarify what you mean by "embedded an empty 100MB file". What does "empty" mean and how did you "embed" it? Can you show us an example of what you're trying to do (obviously replacing the 100MB of "empty" with a placeholder).

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/344ddfba-aea4-4631-b283-202a967f4b02n%40googlegroups.com.


--
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

Aurora

unread,
Dec 16, 2022, 2:15:24 AM12/16/22
to golang-nuts
By empty, I mean it didn't actually contain any actual data, just zeros.
That's why it's being compressed that much.
I embedded the file into the Go code using the standard embed directive.

```
package main 
  
 import _ "embed" 
  
 //go:embed .empty 
 var data []byte
```

Dmitriy P

unread,
Dec 16, 2022, 7:03:01 AM12/16/22
to golang-nuts
It seems you not interact with data variable in main or other places, so go automatically drop it

Just add `print(len(data))` or something like this in main function and binary instantly grow up

пятница, 16 декабря 2022 г. в 10:15:24 UTC+3, Aurora:
Reply all
Reply to author
Forward
0 new messages