Home / golang

Golang Debug Third Party Libraries Code on Local Machine

Posted on:2020-06-03 Views:12901 Words:154

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.

Solutions

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.

Reference.