Giter Site home page Giter Site logo

godev's Introduction

Purpose

A docker image to enable golang program develop and debug(with gdb) in any OS, whether macOS or Windows, where installing gdb is rather troublesome.

Explanation

  • Choosing ArchLinux(Instead of Alphine or other Debian distro) is simply because personally I like the lightweighted distro with the (almost) most efficient package manager.

  • vim is added for temporal modification of source code in the container directly.

  • git is added to avoid the git related error if you happens to enter git command in the container (Maybe I will remove it later??).

  • Other command line related tools/programs(e.g. tmux, screen .etc) are not installed in the image

Hint

To run gdb properly with this image, please append privilege param to docker run: Do remember to replace the /gopath/on/host with the absolute $GOPATH on your host.

docker run --privileged --mount type=bind,source=/gopath/on/host,target=/ws -it phye/godev:latest /bin/bash

Example

Say that you're developing golang programs in macOS and want to debug your golang binary using gdb, here is typical steps:

  1. Write your golang code in macOS under your GOPATH. Let's assume that algobase package contains some basic component, while playground directory is the main package which uses algobase package, and thus we have the following layout:
$ echo $GOPATH
/ws/go
$ ls $GOPATH/src/github.com/phye
algobase playground
  1. Now you need to debug your code in playground directory in macOS, all you need to do is:
$ docker run --privileged --mount type=bind,source=/ws/go,target=/ws -it phye/godev:latest /bin/bash
(container)$ cd /ws/go/src/github.com/phye/playground
(container)$ go build -gcflags "-N -l" sth.go
(container)$ gdb sth
(container gdb) break 33
(container gdb) r # Other gdb commands you like to use during debug

godev's People

Contributors

phye avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.