magiconair / properties

Java properties scanner for Go
BSD 2-Clause "Simplified" License
323 stars 77 forks source link

LoadAll significantly increases code size #76

Open justfalter opened 1 month ago

justfalter commented 1 month ago

Compare the two:

The following compiles to 6.6MB w/ go1.22.5 on osx (arm64)

package main

import (
    "github.com/magiconair/properties"
)

func main() {
    _, err := properties.LoadFile("./config.properties", properties.UTF8)
    if err != nil {
        panic(err)
    }
}

The following compiles to 3.7MB:

package main

import (
    "github.com/magiconair/properties"
)

func main() {
    loader := &properties.Loader{Encoding: properties.UTF8}
    _, err := loader.LoadFile("./config.properties")
    if err != nil {
        panic(err)
    }
}

The reason for this is because properties.LoadFile funnels through Loader.LoadAll, which can load properties files from URLs, so net/http and everything gets pulled in.