Editing Core Packages

I am trying to put some fmt.Println ("", “”) in some core methods (crypto/rsa) so I can see what is going on in an attempt to debug something that isn’t working.
When I call GO build of Go Install it knows that the rsa.go is missing import “fmt”, so it is trying to compile the method, but when I added the Import and ran the build I don’t get the output.

The binary downloads of Go from golang.org/dl are magic (in a way that I forget exactly how it works), in that they don’t rebuild the std packages from source. This is to be less reliant on timestamps being correct etc after unpacking/installation.

If you download and build Go from source it’ll probably work closer to how you expect.

Thanks, is there anyway to force it to use my method.

You need to edit the source on GOROOT

That is what I have done, but it didn’t work from what I can tell.
Are you sure it should work?

This may be my nooby interpretation but iirc I read that go compiles fast because it doesn’t actually recompile most of the stuff but just compiles the packages and then stuffs them together (also with magic).
Considering that I found the src but also the pkg folder in GOROOT. I’d now assume golang uses the .a files in pkg and doesn’t recompile your changes - so maybe if you delete the specific .a file, go would recompile it?

You don’t need to delete the .a file, the go tool can tell when a cached package is stale compared to its source.

1 Like

I still can’t get it to work, have tried deleting the .a’s but that didn’t help ???

As I said above you should not need to delete anything, if you have install Go correctly, then this should be automatic.

Let’s start from the top.

What did you do ? Please show output

What did you expect to happen?

What happened instead? Please show output

Have you tried go build -a

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.