Skip to content
This repository has been archived by the owner on May 21, 2023. It is now read-only.

doesn't work with my local project #3

Closed
jerome-laforge opened this issue Jan 12, 2022 · 7 comments
Closed

doesn't work with my local project #3

jerome-laforge opened this issue Jan 12, 2022 · 7 comments
Assignees

Comments

@jerome-laforge
Copy link

in my local project (that means directory with go.mod & go.sum), when I run

cd myWonderfullProject

ls 
go.mod  go.sum main.go

gocap generate .
could not parse package path

I expect that go.cap has been generated with all modules (direct & transitive) pined into my go.mod & go.sum.

@cugu
Copy link
Owner

cugu commented Jan 12, 2022

Can you provide some more information? The content of the main.go and the output of go list --json . should help.

@cugu cugu self-assigned this Jan 12, 2022
@jerome-laforge
Copy link
Author

jerome-laforge commented Jan 12, 2022

I think the root cause is the directory, that contains go.mod & go.sum, doesn't contain go files, that is not acctually in my previous given example.

so I give another example:

mkdir -p /tmp/myWonderfullProject/cmd/myWonderfullProject
cd /tmp/myWonderfullProject

echo 'package main

import "github.com/gin-gonic/gin"

func main() {
        r := gin.Default()
        r.GET("/ping", func(c *gin.Context) {
                c.JSON(200, gin.H{
                        "message": "pong",
                })
        })
        r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}' > /tmp/myWonderfullProject/cmd/myWonderfullProject/main.go


go mod tidy
tree /tmp/myWonderfullProject
/tmp/myWonderfullProject
├── cmd
│   └── myWonderfullProject
│       └── main.go
├── go.mod
└── go.sum

gocap generate /tmp/myWonderfullProject
could not parse package path

@Dentrax
Copy link

Dentrax commented Jan 12, 2022

+1, If I run the following, there is an error in the go.cap file: could not parse package path:

$ gocap generate github.com/sigstore/cosign > go.cap
$ cat go.cap
could not parse package path

@cugu
Copy link
Owner

cugu commented Jan 12, 2022

In these cases /tmp/myWonderfullProject and github.com/sigstore/cosign are not Go packages (they do not contain any go files). gocap generate works on package basis. I should elaborate that more in the readme.

cd /tmp/myWonderfullProject && gocap generate ./cmd/myWonderfullProject > go.cap should work.
as well as
gocap generate ./cmd/cosign > go.cap (although this melts my CPU and takes 5min on my laptop because of the high number of dependencies).

Then you can check with cd /tmp/myWonderfullProject && gocap check ./cmd/myWonderfullProject or gocap check ./cmd/cosign

@jerome-laforge
Copy link
Author

cd /tmp/myWonderfullProject && gocap generate ./cmd/myWonderfullProject > go.cap should work.
as well as

Thx for this workaround, it works fine.
Maybe you can just close this issue, after you will update the readme?

@cugu cugu closed this as completed Jan 12, 2022
@Dentrax
Copy link

Dentrax commented Jan 12, 2022

@cugu thanks for clarification. But the following check command does not read go.cap file i think. 🤔

$ gocap generate ./cmd/myWonderfullProject > go.cap
$ gocap check go.cap
could not parse package path

@cugu
Copy link
Owner

cugu commented Jan 12, 2022

Try gocap check ./cmd/myWonderfullProject

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants