mock icon indicating copy to clipboard operation
mock copied to clipboard

Loading input failed: failed parsing source file internal/handler/handler: open internal/handler/handler: The system cannot find the path specified.

Open melitadn opened this issue 3 years ago • 2 comments

@mrgAndysm Can you please re-create this issue with our template and give more information how to reproduce. Thanks!

Originally posted by @codyoss in https://github.com/golang/mock/issues/652#issuecomment-1179214001

hi i also encounter the same issue while trying to generate the mock file project structure : C:/.../parent/internal/handler/handler.go C:/.../parent/internal/mocks/mock_handler.go

currently, I generate/execute from a command prompt on windows, and I am on the parent folder go mock version = mockgen --version v1.6.0

set GOHOSTARCH=amd64 set GOHOSTOS=windows set GO111MODULE=on set GOARCH=amd64 set GOVERSION=go1.18 set GOOS=windows set GOSUMDB=off set GOEXE=.exe

i have try to add _ "github.com/golang/mock/mockgen/model" and generated it using go mod vendor i already have go mod file generated from go mod init as well

mockgen -source=internal/handler/handler.go -destination=internal/mocks/mock_handler.go -package=mocks --build_flags=--mod=mod
2022/07/19 16:35:41 Loading input failed: failed parsing source file internal/handler/handler: open internal/handler/handler: The system cannot find the path specified.

before this i did this step

  1. go install github.com/golang/mock/[email protected]
  2. go get github.com/golang/mock/mockgen/model
  3. mockgen -source=internal/handler/handler.go -destination=internal/mocks/mock_handler.go -package=mocks

i can only generate the file if i tell exactly where the file is for example : mockgen -source=C:/go/parent/internal/handler/handler.go -destination=internal/mocks/mock_handler.go -package=mocks

but file that was generated, only include the package without go extention // Code generated by MockGen. DO NOT EDIT. // Source: C:/go/parent/internal/handler/handler.go

// Package mock_handler is a generated GoMock package. package mock_handler

melitadn avatar Jul 19 '22 09:07 melitadn

I am unable to reproduce this. Can you please create a small sample repo to reproduce this? I made this folder structure and it generated to mock.

codyoss avatar Aug 12 '22 15:08 codyoss

Dear @codyoss

please find the small sample repo and i have attached picture explanation on how i generate in my local image

https://github.com/melitadn/go-mock-test/

melitadn avatar Aug 15 '22 04:08 melitadn