Ask coding questions

← Back to all posts
How to import local packages in go?
alexalikiotis (5)

Is there any way i can import some local packages into my main.go file ??

e.x
-root
---main.go
---pkg
------pkg.go

I want to import the package 'pkg' to main.go

Answered by Vandesm14 (2736) [earned 5 cycles]
View Answer
Comments
hotnewtop
Vandesm14 (2736)

I don't think repl.it supports packages in Go. If you'd like to have this feature, try posting it to https://repl.it/features

If I answered your question: https://answered--vandesm14.repl.co

alexalikiotis (5)

@Vandesm14 Ohh bummer! Thanks for the answer.

GrahamWalters (5)

This took me a while to figure out, but it is supported as of 2020. Your main would look something like this:

package main

import (
	"main/pkg"
)

func main() {
	pkg.SomeFunc()
}