Git Product home page Git Product logo

Comments (4)

mvdan avatar mvdan commented on August 25, 2024 1

Sorry that I never replied here. To be honest, I've gotten tired of working on the gogrep project for now, and I don't know when I'll actively get back to it. I assume you already saw the refactor branch linked in #32; that was my latest thinking when it comes to a reusable API.

If you want anything other than that, I would suggest to fork or copy code, as that will be the fastest and simplest way. I will probably resurrect/redesign this project at some point in the future, but it's not going to be in the immediate future.

from gogrep.

benjaminjkraft avatar benjaminjkraft commented on August 25, 2024

As an example usage, I have a linter that wants to flag cases where methods of certain types don't call out to their "super" -- that is, where you have a declaration

func (recv *SomeType) SomeMethod(...) ...

which does not call

recv.<something>.SomeMethod(...)

So one part of that is to look for expressions of the form $x.$y.SomeMethod(...), but then we want to get back $x so we can check if it's a reverence to recv (easy, using go/types); and more importantly we only want to do the entire search within some function-declaration. Ideally, we might even vary look for a specific $y depending on the type we're looking at. (Right now we're just doing manual ast traversal -- call, ok := node.(*ast.CallExpr); if !ok { return false } and repeat -- and it's kind of a mess, which is why I'm looking at gogrep.)

The former constraint we could do with some loss of fidelity (due to shadowing) with gogrep alone, something like func ($x $_) $y($*_) $*_ { $*_; $x.$_.$y($*_); $*_ }. But the latter two we really just need types to figure out. I guess in principle we could call out to gogrep to search for each func ($x <specific type>) <specific method-name>($*_) ..., but that seems at best very slow. Of course, we could ask for a way to search " within ", but that feels like a kludge on both sides: you have to add a bunch of syntax, and we are still very constrained in what we can do.

from gogrep.

benjaminjkraft avatar benjaminjkraft commented on August 25, 2024

Totally understandable and appreciate the guidance! I'll post here if I end up forking.

from gogrep.

ole108 avatar ole108 commented on August 25, 2024

@benjaminjkraft I would love to have an API, too.
We might be able to work together on it.

from gogrep.

Related Issues (20)

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.