Giter Site home page Giter Site logo

go-watcher's Issues

Panic when running watcher

Hi, I have a panic when I run go-watcher

go env

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/alex/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/alex/go"
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build165720837=/tmp/go-build -gno-record-gcc-switches"

Command

$ watcher

Error

2018/03/11 19:40:05 Could not run the go binary: exec: "-.-785150": executable file not found in $PATH 
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x46ef4e]

goroutine 7 [running]:
os.(*Process).signal(0x0, 0x502320, 0x56c0e8, 0x0, 0x0)
	/usr/lib/go/src/os/exec_unix.go:56 +0x2e
os.(*Process).Signal(0x0, 0x502320, 0x56c0e8, 0xc42008e100, 0xc420090120)
	/usr/lib/go/src/os/exec.go:129 +0x3f
os.(*Process).kill(0x0, 0xc4200900f0, 0x2)
	/usr/lib/go/src/os/exec_posix.go:54 +0x43
os.(*Process).Kill(0x0, 0x0, 0x54)
	/usr/lib/go/src/os/exec.go:114 +0x2b
github.com/canthefason/go-watcher.(*Runner).kill(0xc42000a160, 0xc4201122c0)
	/home/alex/go/src/github.com/canthefason/go-watcher/run.go:66 +0x41
github.com/canthefason/go-watcher.(*Runner).Run(0xc42000a160, 0xc42000a0c0)
	/home/alex/go/src/github.com/canthefason/go-watcher/run.go:39 +0x211
created by main.main
	/home/alex/go/src/github.com/canthefason/go-watcher/cmd/watcher/main.go:17 +0x110

If you want to reproduce I just listen on a tcp socket. You can ask for anything else.

vim file jumping

Hi,

I'm using vim to write my .go files and the default behavior of vim is the following:

- write buffer to new file
- delete the original file
- rename the new file

I therefore get a lot of this:

Building project/something...
can't load package: package project/something: no Go files in /home/roland/go/src/project/something
An error occurred while building: exit status 1

My guess is that this has something to do with timers. Your watcher seems to update faster than vim writes/moves the file. Is there any way to modify that?

MacOS Catalina: Does not work

It does not work with the following message:

$ watcher
2019/10/24 21:02:15 build started
Building ....
2019/10/24 21:02:17 build completed
Running ...
2019/10/24 21:02:17 process interrupted: signal: killed

Other people from my team who upgraded to Catalina report the same

$ go version
go version go1.12.9 darwin/amd64

Add an option for sending SIGINT instead of SIGKILL

With each file change, we are sending SIGKILL command for killing the running process. The problem is, it would leave some open connections behind. For the programs that require graceful shutdowns, it is better to have an optional SIGINT support for go-watcher.

Add polling

On Windows using Docker inotify from the filesystem won't pick up changes. Can you add an option for polling changes?

Missing WORKDIR leads to building failure

I was testing your Docker right now and I was having a weird issue. Even if I mapped the Volume correctly, I was having this output by watcher:

can't load package: package .: no buildable Go source files in /go

Then after some trials, I found that the issue was mainly because you're missing the WORKDIR declaration in the Dockerfile.

For now I fixed it by declaring it on the docker run command line, although would be nice to have it directly there.

Thanks again and keep up with this awesome project :)

Could not run the go binary

taras@taras-Z370-HD3P /media/taras/Storage/source/server-panel $ watcher
2018/02/10 17:52:26 build started
Building ....
2018/02/10 17:52:27 build completed
Running ...
2018/02/10 17:52:27 Could not run the go binary: exec: "-.-533426": executable file not found in $PATH
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4718b8]

goroutine 7 [running]:
os.(*Process).signal(0x0, 0x573800, 0x5720e8, 0x0, 0x0)
/usr/local/go/src/os/exec_unix.go:56 +0x38
os.(*Process).Signal(0x0, 0x573800, 0x5720e8, 0x54, 0xc420082180)
/usr/local/go/src/os/exec.go:121 +0x3f
os.(*Process).kill(0x0, 0xc4200840f0, 0x2)
/usr/local/go/src/os/exec_posix.go:53 +0x43
os.(*Process).Kill(0x0, 0x0, 0x54)
/usr/local/go/src/os/exec.go:106 +0x2b
github.com/canthefason/go-watcher.(*Runner).kill(0xc42000a500, 0xc42014e160)
/home/taras/go/src/github.com/canthefason/go-watcher/run.go:66 +0x41
github.com/canthefason/go-watcher.(*Runner).Run(0xc42000a500, 0xc42000a080)
/home/taras/go/src/github.com/canthefason/go-watcher/run.go:39 +0x23c
created by main.main
/home/taras/go/src/github.com/canthefason/go-watcher/cmd/watcher/main.go:17 +0x120

Windows: Only one usage of each socket address (protocol/network address/port) is normally permitted.

My go app is a http server with go routines.
When I run it the first time it's fine

watcher -c config -p 7777 -run /c/Projects/go/src/gitlab.com/jeremyjohn/http-project -watch gitlab.com/jeremyjohn/http-project

It starts two watcher-http-project process up and the main watch process.

But after changes to a .go file i get this error

2019/08/16 23:05:15 build started
Building C:/Projects/go/src/gitlab.com/jeremyjohn/http-project...
2019/08/16 23:05:16 build completed
Running C:/Projects/go/src/gitlab.com/jeremyjohn/http-project...
2019/08/16 23:05:16 listen tcp :7007: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.

Run go get as part of containerized version

Nice tool!

I'm looking at the containerized version and I'd like to add a step to do go get (to get the dependencies installed into the file system on the container). A very little local testing suggests this could be achieved by adding go get ./... just before the exec line in entrypoint.sh.

Happy to do a PR but I thought I'd run the idea past you first. Wdyt?

Is this still maintained?

I've seen no new commits in a number of years and as newer go versions are released issues are being encountered here.

Building with Go 1.20.1: flag provided but not defined: -i

It seems that the watcher can no longer be used with the newest version of Go 1.20.1

The problem is that up until now the -i flag was deprecated and using it gave a warning, but the watcher was successfully building the binary.

From Go 1.20.1 the watcher no longer works, because using the -i flag returns an error, not a warning:

myservice  | flag provided but not defined: -i
myservice  | usage: go build [-o output] [build flags] [packages]
myservice  | Run 'go help build' for details.
myservice  | A build error occurred. Please update your code...

Can you please update the code or would you accept a PR that does that? Thank you!

Does someone know of a alternative similar to the go-watcher which is maintained and supports new Go versions?

startcmd ignores keepalive

Hi,

first of all, thanks for implementing a watcher, which is as small and concise, as I want it to be!!

I've found a little bug in my humble opinion, though:

If you start the watcher with keepalive flag and startcmd flag, and the command returns a non zero.

watcher -cmd="false" --keepalive --startcmd

Travis build fails due Go version

Travis is currently building on versions 1.5 and 1.6 of Go, however runtime.KeepAlive is only present in versions 1.7+ of Go, as referenced here.

This is making most builds fail I think. Error can be seen for the missing field here

# golang.org/x/sys/unix

../../../golang.org/x/sys/unix/ioctl.go:18: undefined: runtime.KeepAlive

../../../golang.org/x/sys/unix/ioctl.go:28: undefined: runtime.KeepAlive

../../../golang.org/x/sys/unix/syscall_linux.go:99: undefined: runtime.KeepAlive

github.com/canthefason/go-watcher/docker-examples/hello

github.com/canthefason/go-watcher/vendor/gopkg.in/fsnotify.v1

The command "eval go get -v -t ./... " failed. Retrying, 2 of 3.

Cannot use watcher in MacOS Mojave

Hello, first of all, I'm sorry for my English, I had help from Google Translator ... rsrs

I'm trying to use your library on MacOS Mojave. For this I followed exactly as it is in README.md:

  • I installed the package through the command: go get github.com/canthefason/go-watcher
  • I installed the binary through the go install github.com/canthefason/go-watcher/cmd/watcher command

But even so it was not possible to run the watcher command on the terminal.

Could you help me, please?

Slow down building process a bit?

Great tool, though there's one big problem. I use other watcher (go-razor's templates watcher) which builds .go templates on change, but seems like 99% of the time go-watcher can't yet get changed templates so it rebuilds with an old version. Maybe there's a quick fix (timeout) for this? Thanks.

Use an idempotent, predictable output filename to prevent firewall warnings

It seems this is unmaintained but figured I'd raise this anyway.

A reason I usually go build -o app.exe ; ./app.exe is to keep security software from treating each compilation as a new binary (because it uses a temporary directory). Otherwise, if the application wants access to certain resources such as network sockets, webcams, sound, etc. then you must hit "allow access" for every compilation.

I went to try this app, and it seems it also uses a different output name for every compilation. Resulting in this:

image

It also doesn't seem to clean up these temporary binaries, which has resulted in my %userprofile%/go/bin directory filling up with executables named watcher-.-(random ID).

need to run above src directory

I'm trying to use watcher with a REST server. I have src and public directories in the application directory. It seems I can't run the watcher command from the application directory and must instead run it from the src directory. But this causes an issue with serving static files because my server expects to find those in ./public, not ../public. Is there any way I can tell watcher to watch the files in src and start it from my application directory?

Wrong test labelling

I was reading the unit test file you've made, and I found a wrong labelling I guess.

At this line you wrote:

expected true, got false

for the .md file. But I guess it should be ( looking at the IF condition ):

expected false, got true

right?

Clear terminal output on re-build

It would be helpful for readability if there was a flag that would tell watcher to clear the terminal when a re-build was started.

If there is a work around that exists currently, please let me know!

Dockerfile without VOLUME

I was wondering how to use your Docker, if you didn't declare a Volume. Which will be the path that it will watch? Can you add support for Volumes? Would be a nice-to-have feature :)

Best regards,
Julian

Add ability to run with -race

As far as I can see there is no option to build Go binaries with the -race flag set; the go build command is hard-coded as:

cmd, err := runCommand("go", "build", "-i", "-o", fileName, pkg)

did I miss something?

Could this option be added? Perhaps it would be good to allow passing arbitrary flags to go build; maybe after --?

watcher -c appflag -run example.com/pkg -- -race

Or maybe something like?

watcher -c appflag -run example.com/pkg -buildflags '-race'

Can't find fsnotify

Getting errors while on go get:

build github.com/canthefason/go-watcher/cmd/watcher: cannot load gopkg.in/fsnotify.v1: cannot find module providing package gopkg.in/fsnotify.v1

Could this one be related?

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.