0

I am facing issue in importing a gitsubmodule containing golang package with go.mod and go.sum file inside the package inside main project directory. But facing issue in importing the package.

go.mod inside gitsubmodule package

module abc

go 1.18

go.mod inside main project directory

module def

go 1.18

files inside the gitsubmodule go package has imports

package abc

import "abc/sample"

file for main project package

package main

import "def/abc/sample"


the structure of my project code is like this:-

|── go.sum
|── go.mod
|── main.go import "def/abc"
abc
    ├── constant
    |    ├── constant.go
    ├── abc.go  ----> import "abc/constant"
    |── go.mod
    |── go.sum

and but import "abc/constant" giving problem for gitsubmodule saying import error when I try to run main.go file

1
  • 2
    You say "an issue", but you don't say what issue. What command(s) are you running? What do you expect them to produce and what do they do instead? See How to Ask. Commented May 17, 2022 at 16:29

1 Answer 1

1

the solution to this problem is inside the main go.mod file add the following line

replace abc => ./abc

and do go mod tidy

Sign up to request clarification or add additional context in comments.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.