Availability of header guards

Is there any availability of header guards to avoid cyclic dependency of packages?

What do you mean? You don’t need header guards; the compiler already avoids cyclic package dependencies:

$ go build ./a
can't load package: import cycle not allowed
package ./a
	imports ../b
	imports ../a
1 Like

yes I get the same error

So what is your question then?

Perhaps you’re actually asking about the availability of header guards to avoid allow cyclic dependency of packages? If so, then no, you cannot do this. Go has a strict package initialization order that you can’t establish with cyclic package dependencies.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.