I am creating a web API.
I built my server and controller in the same file main.go
.
I created another file name model.go
where I declare a Person
struct.
I can't export my model in main.go
.
Every time I run or build I get this error :
can't load package: package .: found packages main
Is there a way to export func/const and import them in file with good path? (Like the way JavaScript works).
This is my tree:
myapp/
--main.go/
--model.go/
This is my import: main.go
package main
import (
"encoding/json"
"log"
"net/http"
"./person"
"github.com/gorilla/mux"
)
model.go
package person
type Person struct {
ID string `json:"id,omitempty"`
Firstname string `json:"firstname,omitempty"`
Lastname string `json:"lastname,omitempty"`
Address *Address `json:"address,omitempty"`
}
var people []Person