Giter Site home page Giter Site logo

closecheck's People

Contributors

bradleyfalzon avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

closecheck's Issues

Libraries providing Constructor and Close method

Library authors that have a constructor, such as func New() *T which also has a func (*T) Close() error will have an error reported in the constructor.

This maybe fixed with some special case handling by checking if the type has a locally defined Close() method (somehow).

Caddy

Caddy has an edge case where it's complaining something isn't closed, but technically it eventually is, and closecheck should handle this. This maybe too complex to handle, but ideally, closecheck should decide that it couldn't tell, so it shouldn't error.

I need to investigate why (probably as it's wrapped in a struct+map.

151     restartFds := make(map[string]restartPair)
152     for _, s := range i.servers {
153         gs, srvOk := s.server.(GracefulServer)
154         ln, lnOk := s.listener.(Listener)
155         if srvOk && lnOk {
156             restartFds[gs.Address()] = restartPair{server: gs, listener: ln}
157         }
158     }
...
163     // attempt to start new instance
164     err := startWithListenerFds(newCaddyfile, newInst, restartFds)
165     if err != nil {
166         return i, err
167     }

Eventually it is closed:

547         if gs, ok := s.(GracefulServer); ok && restartFds != nil {
548             addr := gs.Address()
549             if old, ok := restartFds[addr]; ok {
550                 file, err := old.listener.File()
551                 if err != nil {
552                     return err
553                 }
554                 ln, err = net.FileListener(file)
555                 if err != nil {
556                     return err
557                 }
558                 file.Close()
559             }
560         }

Panic in github.com/ncw/swift

panic: interface conversion: ast.Expr is *ast.SelectorExpr, not *ast.Ident

goroutine 1 [running]:
panic(0x65fba0, 0xc42caba7c0)
        /usr/local/go/src/runtime/panic.go:500 +0x1a1
github.com/bradleyfalzon/closecheck.(*visitor).Visit(0xc42cab5890, 0x7f3b4da89d28, 0xc420ce8990, 0x1, 0xc4212334a0)
        /home/bradleyf/go/src/github.com/bradleyfalzon/closecheck/closecheck.go:235 +0x674
go/ast.Walk(0x7b7400, 0xc42cab5890, 0x7f3b4da89d28, 0xc420ce8990)
        /usr/local/go/src/go/ast/walk.go:52 +0x63
go/ast.walkStmtList(0x7b7400, 0xc42cab5890, 0xc420944420, 0x2, 0x2)
        /usr/local/go/src/go/ast/walk.go:32 +0x89
go/ast.Walk(0x7b7400, 0xc42cab5890, 0x7b7e80, 0xc420f1c1e0)
        /usr/local/go/src/go/ast/walk.go:224 +0x1d48
go/ast.Walk(0x7b7400, 0xc42cab5890, 0x7b80c0, 0xc420ce8a40)
        /usr/local/go/src/go/ast/walk.go:98 +0x2ffa
go/ast.Walk(0x7b7400, 0xc42cab5890, 0x7b7ec0, 0xc4207fc100)
        /usr/local/go/src/go/ast/walk.go:136 +0x11f5
go/ast.Walk(0x7b7400, 0xc42cab5890, 0x7f3b4da89f68, 0xc420ce8a50)
        /usr/local/go/src/go/ast/walk.go:213 +0x2054
go/ast.walkStmtList(0x7b7400, 0xc42cab5890, 0xc420285580, 0x8, 0x8)
        /usr/local/go/src/go/ast/walk.go:32 +0x89
go/ast.Walk(0x7b7400, 0xc42cab5890, 0x7b7e80, 0xc420f1c840)
        /usr/local/go/src/go/ast/walk.go:224 +0x1d48
go/ast.Walk(0x7b7400, 0xc42cab5890, 0x7f3b4ddac220, 0xc4207fc340)
        /usr/local/go/src/go/ast/walk.go:231 +0x1f1a
go/ast.walkStmtList(0x7b7400, 0xc42cab5890, 0xc4219c6600, 0xc, 0x10)
        /usr/local/go/src/go/ast/walk.go:32 +0x89
go/ast.Walk(0x7b7400, 0xc42cab5890, 0x7b7e80, 0xc420f1ca80)
        /usr/local/go/src/go/ast/walk.go:224 +0x1d48
go/ast.Walk(0x7b7400, 0xc42cab5890, 0x7b8080, 0xc420f1cab0)
        /usr/local/go/src/go/ast/walk.go:344 +0xf03
github.com/bradleyfalzon/closecheck.Check(0xc420675000, 0xc4202404d0, 0xc42aba1eb8, 0x0, 0x1)
        /home/bradleyf/go/src/github.com/bradleyfalzon/closecheck/closecheck.go:37 +0x1a3

Code:

233                 if interfaceCloses(iface) {
234                     // Function's argument requires an io.Closer, it will likely close it
235                     argIdent := fun.Args[i].(*ast.Ident)
236                     if argIdent != nil {
237                         v.addClosed(v.pi.ObjectOf(argIdent).Pos())
238                     }
239                 }

Offending line:

 314             checkClose(resp.Body, &err)

argIdent probably just needs to be swapped around for exprDef function.

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.