Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json is not being generated :-( #87

Closed
marcelloh opened this issue Apr 24, 2024 · 10 comments
Closed

json is not being generated :-( #87

marcelloh opened this issue Apr 24, 2024 · 10 comments
Labels
bug Something isn't working done trace the trace package

Comments

@marcelloh
Copy link

This is my command:

xgo test -v -run TestTodoController_Suite --strace ./interfaces/controllers

And this is my output:
Notice the warnings at the top....

go: -replace=../MHGoLib=/Users/marcelloh/data/Go/go-private/SBC/MHGoLib: invalid old path: malformed import path "../MHGoLib": invalid path element ".."
WARNING: --strace requires: import _ "github.com/xhd2015/xgo/runtime/trace"
   failed to auto import github.com/xhd2015/xgo/runtime/trace: exit status 1
=== RUN   TestTodoController_Suite
=== RUN   TestTodoController_Suite/Test_TodoController_EditRecord_Error_ID
=== RUN   TestTodoController_Suite/Test_TodoController_EditRecord_Good
=== RUN   TestTodoController_Suite/Test_TodoController_EditRecord_Wrong
=== RUN   TestTodoController_Suite/Test_TodoController_GetMoreRecords
=== RUN   TestTodoController_Suite/Test_TodoController_GetMoreRecordsJSON
=== RUN   TestTodoController_Suite/Test_TodoController_GetMoreRecordsJSON_Error
=== RUN   TestTodoController_Suite/Test_TodoController_GetOneRecord
=== RUN   TestTodoController_Suite/Test_TodoController_GetOneRecordJSON_Error_ID
=== RUN   TestTodoController_Suite/Test_TodoController_GetOneRecordJSON_Error_Wrong
=== RUN   TestTodoController_Suite/Test_TodoController_GetOneRecordJSON_Good
=== RUN   TestTodoController_Suite/Test_TodoController_GetOneRecord_Error_ID
=== RUN   TestTodoController_Suite/Test_TodoController_GetOneRecord_Error_Wrong
=== RUN   TestTodoController_Suite/Test_TodoController_SaveRecord_Error_ID
=== RUN   TestTodoController_Suite/Test_TodoController_SaveRecord_Good
=== RUN   TestTodoController_Suite/Test_TodoController_SaveRecord_Wrong
=== RUN   TestTodoController_Suite/Test_TodoController_SaveRecord_WrongValidation
--- PASS: TestTodoController_Suite (0.03s)
    --- PASS: TestTodoController_Suite/Test_TodoController_EditRecord_Error_ID (0.00s)
    --- PASS: TestTodoController_Suite/Test_TodoController_EditRecord_Good (0.00s)
    --- PASS: TestTodoController_Suite/Test_TodoController_EditRecord_Wrong (0.00s)
    --- PASS: TestTodoController_Suite/Test_TodoController_GetMoreRecords (0.00s)
    --- PASS: TestTodoController_Suite/Test_TodoController_GetMoreRecordsJSON (0.00s)
    --- PASS: TestTodoController_Suite/Test_TodoController_GetMoreRecordsJSON_Error (0.00s)
    --- PASS: TestTodoController_Suite/Test_TodoController_GetOneRecord (0.00s)
    --- PASS: TestTodoController_Suite/Test_TodoController_GetOneRecordJSON_Error_ID (0.00s)
    --- PASS: TestTodoController_Suite/Test_TodoController_GetOneRecordJSON_Error_Wrong (0.00s)
    --- PASS: TestTodoController_Suite/Test_TodoController_GetOneRecordJSON_Good (0.00s)
    --- PASS: TestTodoController_Suite/Test_TodoController_GetOneRecord_Error_ID (0.00s)
    --- PASS: TestTodoController_Suite/Test_TodoController_GetOneRecord_Error_Wrong (0.00s)
    --- PASS: TestTodoController_Suite/Test_TodoController_SaveRecord_Error_ID (0.00s)
    --- PASS: TestTodoController_Suite/Test_TodoController_SaveRecord_Good (0.01s)
    --- PASS: TestTodoController_Suite/Test_TodoController_SaveRecord_Wrong (0.00s)
    --- PASS: TestTodoController_Suite/Test_TodoController_SaveRecord_WrongValidation (0.00s)
PASS
ok      dev.local/marcelloh/SBC/interfaces/controllers    0.520s
@xhd2015
Copy link
Owner

xhd2015 commented Apr 24, 2024

Hi @marcelloh Thanks for feedback. You can manually add import _ "github.com/xhd2015/xgo/runtime/trace" to your test file, this is a workaround. I'll find the reason later.

@xhd2015 xhd2015 added the bug Something isn't working label Apr 24, 2024
@xhd2015
Copy link
Owner

xhd2015 commented Apr 24, 2024

This maybe related to relative replace path not handled correctly. By the way, which go version are you using? Is there a go.work file?

@marcelloh
Copy link
Author

go version
go version go1.22.2 darwin/arm64

and no go.work file

@xhd2015
Copy link
Owner

xhd2015 commented Apr 24, 2024

go version go version go1.22.2 darwin/arm64

and no go.work file

@marcelloh thanks, have you tried adding import _ "github.com/xhd2015/xgo/runtime/trace", does that work?

@marcelloh
Copy link
Author

Yes, that generates a json file, but to add something to the code is not what I hoped for.
So please look at it

@xhd2015
Copy link
Owner

xhd2015 commented Apr 24, 2024

enerates a json f

OK I'll fix this as soon as possible.

@xhd2015
Copy link
Owner

xhd2015 commented Apr 24, 2024

Hi @marcelloh I may ask a few questions:

  1. Is there any replace directive in your go.mod? How do they look like?
  2. Is there a vendor directory?
  3. Can you run with xgo test -v -run TestTodoController_Suite --strace --log-debug=debug.log ./interfaces/controllers, and post the debug.log here? That would be useful, thanks.

@xhd2015
Copy link
Owner

xhd2015 commented Apr 24, 2024

OK so now I'm able to recover the scene that caused this error. This is due to:

  • a relative import in go.mod, e.g. replace some-git.com/my/lib => ../lib
  • with go mod vendor enabled

Solution:
When replaced module is local, do not change it's mod path. This avoids malformed mod path.

@xhd2015
Copy link
Owner

xhd2015 commented Apr 24, 2024

@marcelloh fixed in #90, please try upgrade to v1.0.28 and retry:

go install github.com/xhd2015/xgo/cmd/[email protected]

Please let me know if it has been fixed.

@marcelloh
Copy link
Author

Yes, that is fixed :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working done trace the trace package
Projects
None yet
Development

No branches or pull requests

2 participants