How to develop with Go source code change?

269 views
Skip to first unread message

Rulin Tang

unread,
Jan 2, 2024, 4:45:12 PM1/2/24
to golang-nuts
Hey, I'm trying to do some Go source code development. But I'm confused about how to do the development.

The Go source code is cloned from https://github.com/golang/go master branch. Originally, I run `cd src &^ ./all.bash` to build the latest Go 1.22 version. It works fine.

Then I'm trying to do some source code development. For example, I'm looking at this issue https://github.com/golang/go/issues/64824. It's something about devirtualize.go. So I added two debug lines like  `// fmt.Printf("rulin DevirtualizeAndInlineFunc is called\n")` to `src/compile/internal/interleaved/interleaved.go`.

Then I tried to build an updated Go version with the updated Go source code `./all.bash`. It failed with
```

            rulin DevirtualizeAndInlineFunc is called

            rulin DevirtualizeAndInlineFunc is called

            rulin DevirtualizeAndInlineFunc is called

            rulin DevirtualizeAndInlineFunc is called

            rulin DevirtualizeAndInlineFunc is called

FAIL

FAIL cmd/vet 20.524s

FAIL

go tool dist: Failed: exit status 1

```

My original development plan is to add the debug line, build the updated Go version, run test code with the updated Go version, and check the debug output message at Go source code. Somehow this doesn't work. At least, it stops at the first step to build an updated Go version with debug message.

So here're two questions: 1. What did I do wrong in above steps? 2. Do I have to rebuild Go version every time I make changes to Go source code? and then use the updated Go version to test other existing Go code.

Thanks!

TheDiveO

unread,
Jan 3, 2024, 9:24:25 AM1/3/24
to golang-nuts
Maybe your output is interfering with the way the go code base does some of it's checks; based on the fail in cmd/vet maybe this could be involved: https://github.com/golang/go/blob/b25f5558c69140deb652337afaab5c1186cd0ff1/src/cmd/vet/vet_test.go#L197?

Rulin Tang

unread,
Jan 3, 2024, 2:50:47 PM1/3/24
to golang-nuts
Try it again. And this time it works to build the new Go version. But the debug message doesn't show. Not sure this is the expected result or not.

Rulin Tang

unread,
Jan 4, 2024, 1:17:45 PM1/4/24
to golang-nuts
Thanks TheDiveO, I will double check.

Jason Phillips

unread,
Jan 4, 2024, 3:27:22 PM1/4/24
to golang-nuts
Note that just because there was a unit test failure doesn't mean the Go toolchain you built is not working. all.bash runs make.bash followed by run.bash. If I remember correctly, and if things haven't changed drastically since the last time I did it, the only required step for a usable toolchain is running make.bash.

So I think your best options are:

1. Ignore the unit test error since it's expected, based on your changes
2. Update the go toolchain unit tests to expect your new print statement

Reply all
Reply to author
Forward
0 new messages