Undefined package.function

Hi all,

I was trying to create a small program using clean architecture . So I have some problems when I want to call a function from one package to another one. For example,

In main.go I have :

import (

a := infrastructure.Test(“hello”)
When I made go build I receive this error: undefined infrastructure.Test

and in infrastructure package I have:

package infrastructure

func Test(a string) string{
return a

The tree of the application is:


etc …

Can you help me please ?

Assuming project is under your $GOPATH then your main.go should look like this:

package main

import (


func main() {
	a := infrastructure.Test("hello")

If you are not familiar with the concept of $GOPATH please read How to Write Go Code. Here are some helpful videos that show the basics of workspaces, testing etc. [1] [2].

If you are already familiar with the basics and you are looking for a good way to organize your code then I highly recommend reading Standard Package Layout.

1 Like

Is this typo also in the original code?

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