Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package has dependency of GoGO protobufs and too mainy inits #80

Open
linux019 opened this issue Jul 28, 2021 · 10 comments
Open

Package has dependency of GoGO protobufs and too mainy inits #80

linux019 opened this issue Jul 28, 2021 · 10 comments

Comments

@linux019
Copy link

When inspecting go binary I found that it requires gogo protobufs

gogoError := gogostatus.Error(codes.Unknown, "")
in init()
I do not use gogo in production as it is an outdated project gogo/protobuf#691
Please remove init and gogo dependency

@knz
Copy link
Contributor

knz commented Jul 28, 2021

I don't understand your request.

The "extgrpc" sub-package is merely an example:

  1. it's not required by the errors base package. Why do you think it is a dependency?
  2. 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.

@linux019
Copy link
Author

linux019 commented Jul 28, 2021

go build -o main1 main.go
I used this tool https://github.com/jondot/goweight to analyze binary

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

@knz
Copy link
Contributor

knz commented Jul 28, 2021

Ok so the problem is not with the extgrpc package specifically.

We'll look into it

@StevenACoffman
Copy link
Contributor

Yeah, I think this is maybe why I cannot use cockroachdb/errors in the Go playground.

@1379
Copy link

1379 commented Feb 26, 2023

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?

@knz
Copy link
Contributor

knz commented Feb 27, 2023

Yes this is still actively maintained.

@1379
Copy link

1379 commented Mar 11, 2023

Is there any new progress in this problem?After using this library, my program volume has increased a lot

@StevenACoffman
Copy link
Contributor

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

@1379
Copy link

1379 commented Mar 12, 2023

Thanks!

@linux019
Copy link
Author

linux019 commented Apr 1, 2023

GoGo protobufs is a dead project. The dependency on gogo can be removed without any subsequent issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants