Skip to content

healsdata/golang-reload-debug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-reload-debug

An example of using Air (for live reload), Delve (for debugging), and Cobra (for CLI commands) together in Docker for local development.

Highlights

This is intended as a simple example of getting the two tools working together.

For this example, the entry point in the Dockerfile is air

CMD ["air", "-c", ".air.toml"]

On first run and reload, Air builds the new executable.

go build -o ./.dev/main .

Then Air uses Delve to run the Cobra Cmd

dlv exec ... ./.dev/main serve

Usage

To see it in action, you can run docker compose up -d from the root directory.

Reloading

After that, any edit you make to main.go will trigger a reload. You can test it by changing the message in indexHandler to a different string.

Debugging

To configure debugging in Goland, you'll want to follow the steps outlined in Attach to a process on a remote machine

Tools

References

About

An example of using Air and Delve together

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published