Code Monkey home page Code Monkey logo

gin's People

Contributors

andrewpthorp avatar anze3db avatar azyobuzin avatar benbot avatar brianlavall avatar bruderbarna avatar codegangsta avatar dbudworth avatar dsanader avatar francoishill avatar freehaha avatar hbrylkowski avatar ibash avatar jaimeiniesta avatar jamesclonk avatar jgillich avatar jonaz avatar maticz avatar merovius avatar mfzl avatar modocache avatar perelin avatar resurtm avatar savaki avatar scottkf avatar sidbusy avatar tyftler avatar westonplatter avatar

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  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

gin's Issues

Is it possible to watch .html files?

Currently I parse all template files into a variable when the app launches, so any later made changes will not appear, tried using gin -t . -i but the html changes don't seem to do anything. Any information would be great thanks.

Pretty HTML output for build errors / runtime panics

Hi,

Did you plan to add some nice looking HTML output to gin for errors/panics in proxy.go, instead of just the raw string?
Maybe something similar looking to revel could be done:
http://robfig.github.io/revel/img/Panic.png
?

For just build errors the error message parsing to get the filename and linenumber should be pretty simple.
Not sure about panics though.

If you don't have anything like this already planned, I could give it a try if you'd like?

Error occured when saving files

Gin was working perfectly since i got this message when i try to save file.

goroutine 1 [running]:                                                                                                       
runtime.systemstack_switch()
 /usr/local/go/src/runtime/asm_amd64.s:245 fp=0xc8200ad2b8 sp=0xc8200ad2b0                                            
runtime.mallocgc(0xf0, 0x438dc0, 0x0, 0xc820000180)  
/usr/local/go/src/cmd/compile/main.go:32 +0x395 fp=0xc8200adf40 sp=0xc8200ade68                                      
runtime.main()
...
stack continue

Thanx

"silence is golden" principle

I just wanted to say that this principle is stupid and frustrating.

My use case for broadcasting messages:

  • File changes, I want to know that gin acknowledged the change and is now recompiling the server

Support for -tags ?

I have a project I'd like to work on with a certain -tags configuration. The only way I can get this to work with gin is to modify all my files so that my custom tag is the default one.

Make gin work with graceful

Use graceful(https://github.com/stretchr/graceful), we can shutdown the application gracefully.
Gin kill the app in 3seconds(in lib/runner.go), while the connection is still living.
And, the lib/builder.go use go to build binary file, but if the old process is living, the build will fail.
So, I think gin can build the binary to a temp file, then use install instead of copy/mv to overwrite
the binary file. So that We can use gin to work gracefully with graceful.

Of course, install can only used in *nix...

Delays SSE/EventSource responses

I see that Gin has a special case for websockets. It would be super cool if something similar could be done for EventSource.

I think the Accept header in the request or Content-Type header in the response being set to "text/event-stream" would be a good identifier.

Creation of pkg source files

I'm new at Go, and I'm using your package to live reload the source.

I have seen 2 issues. The first one is after a few seconds, of running, files at pkg folder are created. After that happens, I'm no longer able to update the files, since the rebuild is never executed and the newer version of the files is not loaded.

The second issue is some times I see:

http: proxy error: EOF

And after that, the server stops working. I need to stop gin and run it again.

Doesn't seem to work

In terminal:
export PORT=3000
gin -h
[gin] listening on port 0

I'm running the sample negroni code you have listening to port 3000

doesn't seem to work.

precompiled templates

hi, could it be possible to add support for watching other file extensions other than *.go?
i have for instance HTML templates that are read at application startup and i need to watch them too.

i have quick and dirty fix for it in scanChanges function but i was thinking about proper switch that would allow to specify file types to watch.

Shutdown nicely after a os.Interrupt or syscall.SIGTERM

I will try to find some time to analyze gin code and make pull request.
But someone familiar with the code should be able to implement this must faster.

Here is some sample code to implement it.

c := make(chan os.Signal, 2)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
    s := <-c
    log.Print("Got signal: ", s)
    // KILL the application here! 
    os.Exit(1)
}()

gin osx firewall issue

Hi,

I started using gin today, but it keeps invoking OSX firewall each time the app binary is recompiled (in /gin-bin).

Do you want the application “gin-bin” to accept incoming network connections?

I checked if proxy is trying to bind on 0.0.0.0, but thats not the case. So I don't know why is it invoking the firewall popups.

Feature request: show build duration

show build duration (ms)
image

Maybe something like this:

func build(builder gin.Builder, runner gin.Runner, logger *log.Logger) {
    start := time.Now()
    err := builder.Build()
    if err != nil {
        buildError = err
        logger.Println("ERROR! Build failed.")
        fmt.Println(builder.Errors())
    } else {
        // print success only if there were errors before
        if buildError != nil {
            elapsed := float64(time.Since(start).Nanoseconds())
            logger.Println(`Build Successful in ` + fmt.Sprintf(`%.2f`, elapsed/1000000.0) + ` ms`)
        }
        buildError = nil
        if immediate {
            runner.Run()
        }
    }
    time.Sleep(100 * time.Millisecond)
}


Test failures due to race conditions

I guet sporadic test-failures (with the same code) due to race conditions when reading the output of the started command. I had this problem before, I think if a process exits before you can read it's output, it get's lost because the pipe is closed.

Custom build script flag

I'm considering using this with one of my projects but the project has a custom build script that needs to run, i.e. not simply go build. Have you considered adding a flag for a custom build command to run as an alternative to go build?

Incorrect time calcs in scanChanges

I'm using Vagrant, and it frequently has a lot of problems keeping the correct time. This means sometimes I modify a file at 16:16 when time.Now() keeps saying it's 16:12 (and it compiles the app all the time).

This could be easily fixed replacing in this line:
https://github.com/codegangsta/gin/blob/master/main.go#L161

the code:
startTime = time.Now()

by:
startTime = info.ModTime()

I think it doesn't change the functionality at all but it fixes problems when using different clocks.

Strange behavior when reloading in a Docker container

I see this strange behavior when I run gin in a docker container. After making a change, the app will start reloading continuously, often not stopping for 10, 20+ attempts. This does not occur when run in a local environment.

Run arbitrary Go file and watch $GOPATH

I thought I had a standard use-case when I wanted to go run a specific .go file every time it or something in the $GOPATH (where its dependencies live) changes.

But the command gin -t "/go/src" x.go fails with:

[gin] ERROR! Build failed.
can't load package: package .: no buildable Go source files in /go/src

Is there any way to watch $GOPATH from outside of it? (Or also watch items above the current directory)

Arguments to the app

I have an app that takes an argument to a config file. Is there already a way to pass it in that I have missed or could we add it somehow?

Support for ColorGo

I'm using colorgo for coloring the compile output, it would be nice if gin support it too, for example with a certain flag -g or --go-command, for example:

gin -g /home/asd/Dropbox/go/bin/colorgo -i -b /tmp/test-build

Extremely high CPU usage

When I run my Martini server through Gin, CPU usage goes through the roof - 85-100% on one core whilst sitting idle. If I run it without Gin, it's less than 1%.

This has only started happening very recently. Ordinarily I'd suspect my own application code as the culprit, but the fact that it runs fine without Gin would indicate otherwise.

Running on an Ubuntu 12.04 Vagrant box on a Ubuntu 14.10 host.

No change detected when saving files using Sublime Text in Mac OS X

Using Sublime Text 3 to save a server.go file fails to activate reload. Saving the same file using vi, nano or emacs correctly reloads the code. Not sure if this is an issue with Sublime Text, OS X, Go or Gin. My guess would be that Sublime Text uses some kind of non standard OS API call to save files.

  • OS: Mac OS X 10.10.2
  • Go version: 1.4.2
  • Editor: Sublime Text 3 Build 3065

Steps to reproduce:

  1. Run gin
  2. Open Sublime Text and edit some code

Feature Request: flag to change directory before running the binary

Sometims the executable is not on the correct directory (since gin require to be runned on current directory), it would be nice to have a flag for example:
--exec_cd ../../ to change directory before running
or --compile_cd bla/another-service/ to change directory before compiling

Runner doesn't respect "--path" flag

When trying to use the "--path" flag, I was seeing...

$ gin --path $GOPATH/src/github.com/kojustin/mycoolwebserver
[gin] listening on port 3000
2015/12/16 21:18:14 http: proxy error: dial tcp [::1]:3001: getsockopt: connection refused

Running gin directly in the working directory worked fine.

Error with "port" overriden with github.com/namsral/flag

Hi,

I'm using gin for a while and I saw you advice to use "github.com/namsral/flag" in README if we need to override options in our app.

I've got an "-port" option in my app. So I decided to use it.

export PORT=8001
go run myapp.go

That's ok, I can read 8001 port. I stop and do following commands:

Now, I've got "PORT" env var set to ":8001" and I launch gin like this:

gin -a 8001 -p 8000

When I GET 127.0.0.1:8000 I've the error:

http: proxy error: dial tcp 127.0.0.1:8001: connection refused

If I go back to standard "flag" package and I change my program to listen 8001 by default, that works... (I unset PORT env var)

Any idea ?

Adding a release binary

I think it would be nice to have a tagged release binary that users can come download instead of telling the user to go get to install.

Restart when template files were edited

Right now gin only listens to .go files, which requires me to restart the server to see changes to .html files. It might be useful to be able to specify extra file extension to watch.

Usually doesn't restart unless I save twice?

What is up with this? I'll save the file and go reload the page but it's the same old page. I have to go back to my editor and save one more time before the changes are actually reflected. This is not ideal and it's a deal-breaker, not only for me. I've noticed a lot of other developers complaining about this, too.

Why is this happening and how could I potentially fix it?

Full path for -b

It would be nice if gin support full path for -b, for example: gin -b /tmp/out.bin

all we need is to modify inside func MainAction(c *cli.Context) {

        //runner := gin.NewRunner(filepath.Join(wd, builder.Binary()), c.Args()...)
        runpath := builder.Binary()
        if runpath[0] != '/' {
                runpath = filepath.Join(wd, runpath)
        }
        runner := gin.NewRunner(runpath, c.Args()...)

Compiled binary is invalid

After some rebuild, the binary gin builds is invalid.

$ ./gin-bin
-bash: ./gin-bin: cannot execute binary file: Exec format error

Can't load local package

Hey, thanks for making gin!

I'm having a little problem when importing local packages.. It complains with:

can't load package: /x/y/main.go:7:2: local import "./routes" in non-local package

Doesn't happen when i go run main.go.. Any ideas on what i'm doing wrong?

Thanks!

gin fails horribly when go can't be found in $PATH

Might be worth checking whether there's a go binary in $PATH on startup. When setting up a new install recently, I encountered the following immense stacktrace when using a terminal with a misconfigured environment, where gin was in $PATH, but go wasn't:

matt@o:~/go/src/github.com/dgryski/carbonzipper$ gin -- -d=1 -c /etc/carbonzipper.conf -stdout=true
[gin] listening on port 3000
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x8 pc=0x45517e]

goroutine 16 [running]:
runtime.panic(0x6e6bc0, 0x8d70d3)
        /usr/local/go/src/pkg/runtime/panic.c:279 +0xf5
os.(*ProcessState).success(0x0, 0xc20802a230)
        /usr/local/go/src/pkg/os/exec_posix.go:73 +0x1e
os.(*ProcessState).Success(0x0, 0x0)
        /usr/local/go/src/pkg/os/doc.go:72 +0x27
github.com/codegangsta/gin/lib.(*builder).Build(0xc208022c60, 0x0, 0x0)
        /home/matt/go/src/github.com/codegangsta/gin/lib/builder.go:51 +0x159
main.build(0x7f251429c960, 0xc208022c60, 0x7f251429c998, 0xc2080042a0, 0xc208018640)
        /home/matt/go/src/github.com/codegangsta/gin/main.go:135 +0x36
main.MainAction(0xc20806c180)
        /home/matt/go/src/github.com/codegangsta/gin/main.go:112 +0x70f
github.com/codegangsta/cli.(*App).Run(0xc20806c0c0, 0xc208004060, 0x6, 0x6, 0x0, 0x0)
        /home/matt/go/src/github.com/codegangsta/cli/app.go:135 +0x99c
main.main()
        /home/matt/go/src/github.com/codegangsta/gin/main.go:73 +0x32f

goroutine 19 [finalizer wait]:
runtime.park(0x415340, 0x8dbbb0, 0x8d9e49)
        /usr/local/go/src/pkg/runtime/proc.c:1369 +0x89
runtime.parkunlock(0x8dbbb0, 0x8d9e49)
        /usr/local/go/src/pkg/runtime/proc.c:1385 +0x3b
runfinq()
        /usr/local/go/src/pkg/runtime/mgc0.c:2644 +0xcf
runtime.goexit()
        /usr/local/go/src/pkg/runtime/proc.c:1445

goroutine 20 [syscall]:
os/signal.loop()
        /usr/local/go/src/pkg/os/signal/signal_unix.go:21 +0x1e
created by os/signal.init·1
        /usr/local/go/src/pkg/os/signal/signal_unix.go:27 +0x32

goroutine 21 [runnable]:
net/http.Serve(0x7f251429ca30, 0xc20803a030, 0x7f251429da88, 0xc208000d20, 0x7f251429ca30, 0xc20803a030)
        /usr/local/go/src/pkg/net/http/server.go:1574
created by github.com/codegangsta/gin/lib.(*Proxy).Run
        /home/matt/go/src/github.com/codegangsta/gin/lib/proxy.go:43 +0x25e

goroutine 22 [runnable]:
main.func·003()
        /home/matt/go/src/github.com/codegangsta/gin/main.go:183
created by main.shutdown
        /home/matt/go/src/github.com/codegangsta/gin/main.go:191 +0x15f

matt@o:~/go/src/github.com/dgryski/carbonzipper$ export PATH=$PATH:$HOME/git_tree/go/bin
matt@o:~/go/src/github.com/dgryski/carbonzipper$ which go
/home/matt/git_tree/go/bin/go
matt@o:~/go/src/github.com/dgryski/carbonzipper$ gin -- -d=1 -c /etc/carbonzipper.conf -stdout=true
[gin] listening on port 3000

Docker integration?

It's pretty straightforward to ship a Go app using e.g. google/golang, but I'm not sure how to setup an environment that works with gin. Any ideas?

Unable to run when binary is on /tmp folder

Purpose: reduce write on disk (/tmp is RAM)

Shell script

gin -i -b "/tmp/gin-bin" "go build test.go && ./tmp/gin-bin"

the output

2014/12/10 15:45:16 http: proxy error: dial tcp 127.0.0.1:3001: connection refused

gin gets confused when used with emacs flymake

It seems that the emacs flymake package works by creating go files prepended with flymak. These are saved as you type so it can report errors within emacs buy seem to be immediately deleted. When this happens, I get errors of the form:

      [gin] ERROR! Build failed.
      # ctxl/l
      open l/flymake_userhttp.go: No such file or directory

gin never seems to recover from this.

is there any way to set gin up so that it doesn't attempt to include files with regex such as flymake_*.go?

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.