Package has dependency of GoGO protobufs and too mainy inits
When inspecting go binary I found that it requires gogo protobufs https://github.com/cockroachdb/errors/blob/72ec75208141a2b67e79909b28aea29ed2189108/extgrpc/ext_grpc.go#L182 in init() I do not use gogo in production as it is an outdated project https://github.com/gogo/protobuf/issues/691 Please remove init and gogo dependency
I don't understand your request.
The "extgrpc" sub-package is merely an example:
- it's not required by the
errorsbase package. Why do you think it is a dependency? - to achieve what it does (error transport across RPCs), the simplest implementation is the one provided, using gogoproto. You are free to implement your own variant of this example which does not use gogoproto.
go build -o main1 main.go I used this tool https://github.com/jondot/goweight to analyze binary
- compiled binary has size 8MB. As you can see from output the binary contains gogo libs that are not used
package main
import (
"log"
"strconv"
"github.com/cockroachdb/errors"
)
func main() {
log.Println(f())
}
func f() error {
_, err := strconv.Atoi("1122")
return errors.Wrap(err, "ttt")
}
~/go/bin/goweight .|head -n 10
7.3 MB runtime
6.3 MB net/http
4.3 MB github.com/gogo/protobuf/proto
3.4 MB github.com/gogo/protobuf/types
2.9 MB net
2.7 MB crypto/tls
2.4 MB reflect
1.7 MB github.com/gogo/protobuf/protoc-gen-gogo/descriptor
1.6 MB math/big
1.5 MB syscall
- Same program, but it uses another errors lib and size of compiled binary it's only 2MB :)
package main
import (
"log"
"strconv"
"github.com/pkg/errors"
)
func main() {
log.Println(f())
}
func f() error {
_, err := strconv.Atoi("1122")
return errors.Wrap(err, "ttt")
}
~/go/bin/goweight .|head -n 10
7.3 MB runtime
2.4 MB reflect
1.5 MB syscall
873 kB time
777 kB os
710 kB internal/reflectlite
694 kB fmt
476 kB strconv
460 kB internal/poll
446 kB strings
Ok so the problem is not with the extgrpc package specifically.
We'll look into it
Yeah, I think this is maybe why I cannot use cockroachdb/errors in the Go playground.
Is there any new progress in this problem? I saw that this library has not been updated for a long time, so I want to ask, is this library still maintained?
Yes this is still actively maintained.
Is there any new progress in this problem?After using this library, my program volume has increased a lot
@1379 This errors package is amazing, but since it has so many features, it makes it very heavy weight. That's just the tradeoff.
However, if you just want to use errors with StackTraces (and don't need protobuf, network portability, PII redaction, etc.) you can just use something like https://github.com/StevenACoffman/simplerr that also reconciles the pkg/errors with std lib errors, but with out the other goodies.
Thanks!
GoGo protobufs is a dead project. The dependency on gogo can be removed without any subsequent issues