Coder Social home page Coder Social logo

zephinzer / godev Goto Github PK

View Code? Open in Web Editor NEW
196.0 12.0 30.0 3.43 MB

Golang development tool that supports project bootstrap, live-reload (tests + application), and auto dependency retrieval based on Go Modules

Home Page: https://getgo.dev

License: MIT License

Dockerfile 3.11% Makefile 12.42% Shell 6.39% Go 78.08%
joeir docker-image golang makefile live-reload dependency-retrieval gorealize gin goconvey bootstrapping

godev's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

godev's Issues

Add .cache to .gitignore

The directory .cache is not ignored by Git, resulting in hundreds of files after dependency resolution

Kubernetes version

Amazing work! I just missed a k8 version. Are you interested / intend to adapt the tool this way?

Auto-Reload not working on Windows

Hi, I love your golang-dev Container but my main work environment is windows.

Unfortunately, docker does not support inotify for windows users.

I have evaluated two solutions to this problem:

  1. Implement a polling mechanism that may be activated by an environment variable.
  2. Use the docker-windows-volume-watcher python package and add attrib to the inotifywait command.

I am going with the second one and will provide a PR soon.

`start` script cannot take in the correct parameters

To replicate this, assuming you have registered a valid flag named -ini, run:

docker run \
    -it \
    --network host \
    -u $$(id -u) \
    -v "$(pwd)/.cache/pkg:/go/pkg" \
    -v "$(pwd):/go/src/app" \
    zephinzer/golang-dev:0.3.2 start --init

The scripts will display the help message instead of running the application with the --init flag.

The expected behaviour should be to start the app with the --init flag, this happens because of the way the entrypoint script is deciding which script to call by evaluating $@ which evaluates to start --init - hence it won't match anything.

Fix this by evaluating $1 in the entrypoint script instead

Create `.cache/pkg` on init

When using a docker-compose.yml with a local user, auto-download of dependencies will fail to complete since the .cache/pkg is created by the Docker engine using a root user

test command does not work when sub-packages are used

Assuming a directory of structure of:

- [d] vendor
- [d] utils
- [d] models
- main.go
- config.go
- config_test.go

Currently, the test command will only run config_test.go instead of the test files in the utils and models directories

COPY scripts twice

A silly observation: The following lines appear repeated in your Dockerfile

COPY --chown=1000:0 ./scripts /scripts
ENV PATH="/scripts:${PATH}"
RUN chmod +x -R /scripts

Not able to achieve the live-Reload

I am using following main.go file:


import (
	"encoding/json"
	"github.com/gorilla/mux"
	"log"
	"net/http"
)

// Response is just a very basic example.
type Response struct {
	Status string `json:"status,omitempty"`
}

// GetStatus returns always the same response.
func GetStatus(w http.ResponseWriter, _ *http.Request) {
	b := Response{Status: "helo arshpreet singh khangra"}
	json.NewEncoder(w).Encode(b)
}

func main() {
	router := mux.NewRouter()
	router.HandleFunc("/status", GetStatus).Methods("GET")
	log.Fatal(http.ListenAndServe(":8123", router))
}

and I am running service like this:

docker run -it -u ${UID} -p 8123:812-v "$(pwd)/.cache/pkg:/go/pkg" -v "$(pwd):/go/src/app" zephinzer/golang-dev:latest start;

But each time I do: curl http://localhost:8123/status

I don't get live changes, instead I have to stop and re-run this "docker run -it -u ${UID} -p 8123:812-v "$(pwd)/.cache/pkg:/go/pkg" -v "$(pwd):/go/src/app" zephinzer/golang-dev:latest start;" in te same terminal.

Unable to install with go get

Unable to install with go get for go1.13.4. Results in following error:

$ go get -v -u github.com/zephinzer/godev
github.com/zephinzer/godev (download)
github.com/fsnotify/fsnotify (download)
get "golang.org/x/sys/unix": found meta tag get.metaImport{Prefix:"golang.org/x/sys", VCS:"git", RepoRoot:"https://go.googlesource.com/sys"} at //golang.org/x/sys/unix?go-get=1
get "golang.org/x/sys/unix": verifying non-authoritative meta tag
golang.org/x/sys (download)
github.com/kballard/go-shellquote (download)
github.com/sirupsen/logrus (download)
github.com/stretchr/testify (download)
get "gopkg.in/yaml.v2": found meta tag get.metaImport{Prefix:"gopkg.in/yaml.v2", VCS:"git", RepoRoot:"https://gopkg.in/yaml.v2"} at //gopkg.in/yaml.v2?go-get=1
gopkg.in/yaml.v2 (download)
github.com/urfave/cli (download)
github.com/cpuguy83/go-md2man (download)
github.com/zephinzer/godev
# github.com/zephinzer/godev
/Users/mraj/go/src/github.com/zephinzer/godev/cli.go:28:20: cannot use []cli.Command literal (type []cli.Command) as type []*cli.Command in assignment
/Users/mraj/go/src/github.com/zephinzer/godev/flags.go:9:23: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in return argument:
        cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
/Users/mraj/go/src/github.com/zephinzer/godev/flags.go:18:23: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in return argument:
        cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
/Users/mraj/go/src/github.com/zephinzer/godev/flags.go:27:23: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in return argument:
        cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
/Users/mraj/go/src/github.com/zephinzer/godev/flags.go:36:28: cannot use cli.StringSliceFlag literal (type cli.StringSliceFlag) as type cli.Flag in return argument:
        cli.StringSliceFlag does not implement cli.Flag (Apply method has pointer receiver)
/Users/mraj/go/src/github.com/zephinzer/godev/flags.go:44:28: cannot use cli.StringSliceFlag literal (type cli.StringSliceFlag) as type cli.Flag in return argument:
        cli.StringSliceFlag does not implement cli.Flag (Apply method has pointer receiver)
/Users/mraj/go/src/github.com/zephinzer/godev/flags.go:52:23: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in return argument:
        cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
/Users/mraj/go/src/github.com/zephinzer/godev/flags.go:61:23: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in return argument:
        cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
/Users/mraj/go/src/github.com/zephinzer/godev/flags.go:70:25: cannot use cli.DurationFlag literal (type cli.DurationFlag) as type cli.Flag in return argument:
        cli.DurationFlag does not implement cli.Flag (Apply method has pointer receiver)
/Users/mraj/go/src/github.com/zephinzer/godev/flags.go:80:3: unknown field 'EnvVar' in struct literal of type cli.StringFlag
/Users/mraj/go/src/github.com/zephinzer/godev/flags.go:80:3: too many errors

$ go version
go version go1.13.4 darwin/amd64

failed to initialize build cache at /.cache/go-build: mkdir /.cache: permission denied

I tried to follow docs, but I get an error with the .cache folder. It seems to use /.cache and not ./.cache ?

➜  server mkdir -p ./.cache/pkg;

➜  server docker run -it \
  -u $(id -u) \           
  -v "$(pwd):/go/src/app" \
  -v "$(pwd)/.cache/pkg:/go/pkg" \
  -w /go/src/app \
  zephinzer/godev:latest \
  godev init
/go/src/app 
Nov02/16:46| [main] godev has started
odev> initialise git repository at '/go/src/app'? [y/N]: y
odev> sure thing
Initialized empty Git repository in /go/src/app/.git/
odev> seed a .gitignore? [y/N]: y
odev> sure thing
odev> seed a go.mod? [y/N]: y
odev> sure thing
odev> seed a main.go? [y/N]: y
odev> sure thing
odev> seed a Dockerfile? [y/N]: y
odev> sure thing
odev> seed a .dockerignore? [y/N]: y
odev> sure thing
odev> seed a Makefile? [y/N]: y
odev> sure thing
Nov02/16:46| [main] godev has ended
➜  server git:(master) ✗ docker run -it \
  -u $(id -u) \
  -v "$(pwd):/go/src/app" \
  -v "$(pwd)/.cache/pkg:/go/pkg" \
  -w /go/src/app \
  zephinzer/godev:latest \
  godev     
Nov02/16:46| [main] godev has started
Nov02/16:46| [main] working dir : '/go/src/app'
Nov02/16:46| [main] watching dir: '/go/src/app'
Nov02/16:46| [command/go] 'mod', 'vendor'
► ─────────────────────────────────────────── pid:12 id:20bcdb ►
go: modules disabled inside GOPATH/src by GO111MODULE=auto; see 'go help modules'
Nov02/16:46| [command/go] 
■ ─────────────────────────────────────────── pid:12 id:20bcdb ■
Nov02/16:46| [run/1/1/3]] command[20bcdb] exited with: exit status 1
Nov02/16:46| [command/go] 'build', '-o', '/go/src/app/bin/app'
► ─────────────────────────────────────────── pid:21 id:c6be74 ►
failed to initialize build cache at /.cache/go-build: mkdir /.cache: permission denied
Nov02/16:46| [command/go] 
■ ─────────────────────────────────────────── pid:21 id:c6be74 ■
Nov02/16:46| [run/1/2/3]] command[c6be74] exited with: exit status 1
Nov02/16:46| [run/1/3/3]] application at '/go/src/app/bin/app' could not be found

Not killing process

service.exe is not being killed therefore I am getting Only one usage of each socket address (protocol/network address/port) is normally permitted

godev --ignore "docs,service.exe,service.exe~" --exec "swag init" --exec "go build -o service.exe main.go route.go" --exec "service.exe" --ar
gs "--server_address 127.0.0.1:8081"
�[�[32m|Jun04/01:30| [main] godev has started
�[0m�[�[32m|Jun04/01:30| [main] working dir : 'E:\coinread\coinread-api'
�[0m�[�[32m|Jun04/01:30| [main] watching dir: 'E:\coinread\coinread-api'
�[0m�[�[32m|Jun04/01:30| [command/swag] 'init'
► ─────────────────────────────────────────── pid:25316 id:bee3d3 ►
�[0m2019/06/04 01:30:18 Generate swagger docs....
2019/06/04 01:30:18 Generate general API Info
2019/06/04 01:30:18 Generating common.HTTPError
2019/06/04 01:30:18 Generating models.Portfolio
2019/06/04 01:30:18 Generating models.PortfolioSymbols
2019/06/04 01:30:18 Generating models.PortfolioSymbol
2019/06/04 01:30:18 Generating models.PortfolioTransactions
2019/06/04 01:30:18 Generating models.PortfolioTransaction
2019/06/04 01:30:18 Generating models.MarketSymbol
2019/06/04 01:30:18 Generating models.Tickers
2019/06/04 01:30:18 Generating models.Ticker
2019/06/04 01:30:18 Generating models.TickerHyperlink
2019/06/04 01:30:18 create docs.go at  docs/docs.go
2019/06/04 01:30:18 create swagger.json at  docs/swagger.json
2019/06/04 01:30:18 create swagger.yaml at  docs/swagger.yaml
�[�[32m|Jun04/01:30| [command/swag]
■ ─────────────────────────────────────────── pid:25316 id:bee3d3 ■
�[0m�[�[32m|Jun04/01:30| [command/go] 'build', '-o', 'service.exe', 'main.go', 'route.go'
► ─────────────────────────────────────────── pid:30840 id:93427a ►
�[0m�[�[32m|Jun04/01:30| [command/go]
■ ─────────────────────────────────────────── pid:30840 id:93427a ■
�[0m�[�[32m|Jun04/01:30| [command/service.exe] '--server_address', '127.0.0.1:8081'
► ─────────────────────────────────────────── pid:31408 id:44b5b0 ►
�[0m2019/06/04 01:30:22 Using high precision timer
time="2019-06-04T01:30:22+06:00" level=info msg="loading config: config.yaml"
time="2019-06-04T01:30:22+06:00" level=info msg="Listening on 127.0.0.1:8081\n" caller="service.go:192"
|Jun04/01:30| [runner] terminating pipeline 1...
|Jun04/01:30| [runner] terminated pipeline 1
|Jun04/01:30| [command/service.exe] not supported by windows
|Jun04/01:30| [command/service.exe]
■ ─────────────────────────────────────────── pid:31408 id:44b5b0 ■
|Jun04/01:30| [run/1/3/3]] command[44b5b0] exited with: interrupt
|Jun04/01:30| [command/swag] 'init'
► ─────────────────────────────────────────── pid:17164 id:bee3d3 ►
2019/06/04 01:30:28 Generate swagger docs....
2019/06/04 01:30:28 Generate general API Info
2019/06/04 01:30:28 Generating common.HTTPError
2019/06/04 01:30:28 Generating models.Portfolio
2019/06/04 01:30:28 Generating models.PortfolioSymbols
2019/06/04 01:30:28 Generating models.PortfolioSymbol
2019/06/04 01:30:28 Generating models.PortfolioTransactions
2019/06/04 01:30:28 Generating models.PortfolioTransaction
2019/06/04 01:30:28 Generating models.MarketSymbol
2019/06/04 01:30:28 Generating models.Tickers
2019/06/04 01:30:28 Generating models.Ticker
2019/06/04 01:30:28 Generating models.TickerHyperlink
2019/06/04 01:30:28 create docs.go at  docs/docs.go
2019/06/04 01:30:28 create swagger.json at  docs/swagger.json
2019/06/04 01:30:28 create swagger.yaml at  docs/swagger.yaml
|Jun04/01:30| [command/swag]
■ ─────────────────────────────────────────── pid:17164 id:bee3d3 ■
|Jun04/01:30| [command/go] 'build', '-o', 'service.exe', 'main.go', 'route.go'
► ─────────────────────────────────────────── pid:14816 id:93427a ►
|Jun04/01:30| [command/go]
■ ─────────────────────────────────────────── pid:14816 id:93427a ■
|Jun04/01:30| [command/service.exe] '--server_address', '127.0.0.1:8081'
► ─────────────────────────────────────────── pid:28700 id:44b5b0 ►
2019/06/04 01:30:33 Using high precision timer
time="2019-06-04T01:30:33+06:00" level=info msg="loading config: config.yaml"
time="2019-06-04T01:30:33+06:00" level=warning msg="listen tcp 127.0.0.1:8081: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted." caller="main.go:60"
|Jun04/01:30| [command/service.exe]
■ ─────────────────────────────────────────── pid:28700 id:44b5b0 ■

Maybe use Mage instead of Makefile

Mage is a golang equivalent of Makefiles.

It's well supported too.

You can compile the mage file into an executable, so each OS host does not need any golang.

The huge advantage is that it make it easy for Windows users to use who don't have Make, and it's very idiot proof.

I started using it and never went back

Getting `Runtime error: index out of range` on MacOS with VSCode

While running GoDev on MacOS, the following error occasionally occurs:

panic: runtime error: index out of range

goroutine 6 [running]:
main.(*WatcherEvent).EventType(...)
        ~/go/src/github.com/zephinzer/godev/watcher.event.go:65
main.(*WatcherEvent).FileType(0xc000350ed8, 0x127678a, 0xc000132070)
        ~/go/src/github.com/zephinzer/godev/watcher.event.go:86 +0x16d
main.(*WatcherEvent).IsAnyOf(0xc000350ed8, 0xc0000984e0, 0x2, 0x2, 0xc000350e01)
        ~/go/src/github.com/zephinzer/godev/watcher.event.go:109 +0x73
main.(*Watcher).watchRoutine(0xc00005a1c0, 0xc000097140, 0xc0002e4f00, 0xc000048bc0, 0xc000048bd0)
        ~/go/src/github.com/zephinzer/godev/watcher.go:91 +0x4a0
created by main.(*Watcher).BeginWatch
        ~/go/src/github.com/zephinzer/godev/watcher.go:64 +0x16b

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.