I’m finding out Golang from Head initially Go. This is my directory site framework for method code.
rashly/.
src/.
instance/.
date.go.
event.go.
// date.go.
bundle instance.
kind Day struct {
day int.
month int.
year int.
}
// event.go.
bundle instance.
kind Occasion struct {
title string.
Day.
}
I’m dealing with Day: undefined
in event.go
despite the fact that they become part of the very same bundle. Just how to manage this?
The headfirst publication straight includes the instance bundle to C:/ go/src
, the go SDK.
I do not actually intend to make modifications there.
Did you run:
go init << module_name>>
Cos if you did, it needs to function.
Simply develop a component and also prevent horning in the go sdk whatsoever, other than you recognize specifically what you’re doing.
Many thanks a heap for your reply!
I did this:
go mod init headfirst// gotten rid of src directory site from headfirst.
go.mod// Included go.mod documents.
// go.mod.
component headfirst.
go 1.20.
if I do this go run main.go
it functions just if main.go is inside headfirst component.
If I develop main.go beyond component, after that import does not function.
Just how to manage this? I attempted including / headfirst
to GOPATH
, yet found this mistake: $ GOPATH/go. mod exists yet need to not
Why would certainly you intend to have your main.go outside the component( headfirst) … ur work space just acknowledges the components of that component, whatever else that would certainly be available in would certainly be an outright course
If you have an interest in “exactly how can 2 regional components speak with each various other”. There’s something called -change in the middle of the go command. Allow me go seek it
Do with this instance tutorial to see exactly how components can speak with each various other
So if you desire ur main.go outside headfirst yet existing in one more component … and also still speak with package in headfirst that instance need to be great. best of luck
What are you doing when you obtain that mistake?
2 Sorts