Joaquin Noé
Joaquin Noé

Reputation: 25

How to import local package in Go?

how can i do to import a package?

myproject

  main.go

  Repository

            DBHelper.go

  Configuration

            Configuration.go

I need to call a function inside DBHelper.go from Configuration.go, how can i do it?

I need to call Select function from Configuration.go Thanks! Regards!

I Call Select but not working(undefined: DBHelper.Select in DBHelper)

Upvotes: 0

Views: 1904

Answers (1)

tier1
tier1

Reputation: 6433

Package imports are relative from your GOPATH

For example, if DBHelper.go uses package "helpers", your import would look like this:

<name of project folder>/Repository/helpers

Here is a very similar question on the subject: How to use custom packages in Go

--Edit

Almost forgot, to perform the actual function call, you must use the package name / alias.

helpers.MyFunc()

Upvotes: 2

Related Questions