Golang Debug Third Party Libraries Code on Local Machine

Updated at: 2020-06-03 Views: 3199 Words: 154 Category: golang

GoAdmin, which is a golang library being used in my golang project, found a bug in the datetime component.

  • Time component cannot be switched Chinese locale
  • Filtering is not effective. Current speculation is that the date formatting is due to locale issues

Wanted to debug it myself to see if it could be fixed.

But how to debug it?

First, I was trying to directly modify the code under GOPATH/src and then recompile it. But found

> ls $GOPATH/src/github.com/GoAdminGroup/

It's empty.


Replace the source with a go mod.

go mod edit -replace github.com/GoAdminGroup/go-admin=/home/zhongwei/work/go-admin

This replaces the github's library with a local version.

Then open the mod file and you will find an extra line at the end of the go.mod file.

replace github.com/GoAdminGroup/go-admin => /home/zhongwei/work/go-admin

Add the debug code, go build compile again, and you'll see the results.


  • https://thewebivore.com/using-replace-in-go-mod-to-point-to-your-local-module/
  • https://stackoverflow.com/questions/39215629/importing-local-changes-of-a-package-without-pushing-code-in-golang

Leave a Comment