dgryski / semgrep-go

Go rules for semgrep and go-ruleguard
MIT License
457 stars 37 forks source link

ruleguard error: could not import github.com/quasilyte/go-ruleguard/dsl #27

Closed ainar-g closed 3 years ago

ainar-g commented 3 years ago

Synopsis:

$ pwd
  /tmp/gomod
$ more *
  ::::::::::::::
  go.mod
  ::::::::::::::
  module example.com/gomod
  ::::::::::::::
  main.go
  ::::::::::::::
  package main

  import "fmt"

  func main() {
        fmt.Println("Hello, world!")
  }
$ go get -v github.com/quasilyte/go-ruleguard/cmd/ruleguard@latest
  go get: added github.com/quasilyte/go-ruleguard v0.3.1
$ ruleguard --debug 'fpstv' --rules "/path/to/ruleguard.rules.go" -c 0 ./main.go
  14:40:54.939917 load [./main.go]
  14:40:55.162670 building graph of analysis passes
  ruleguard: load rules: parse rules file: typechecker error: /path/to/ruleguard.rules.go:5:8: could not import github.com/quasilyte/go-ruleguard/dsl (can't find import: "github.com/quasilyte/go-ruleguard/dsl")
  25.525083ms   ruleguard@command-line-arguments

My version of semgrep-go is 7d35e5cd. Go version is go1.16 linux/amd64.

dgryski commented 3 years ago

Yeah, I think you need to go get the .../dsl package explicitly.

/cc @quasilyte

ainar-g commented 3 years ago

I finally got the time to check, and yes, you have to go get the package with:

env GO111MODULE=off go get github.com/quasilyte/go-ruleguard/dsl

@quasilyte, I think you should update your README, because since Go 1.16 the default behaviour for go get is to use Go modules, so you need an explicit GO111MODULE=off to actually put the package into $GOPATH/src.