从本地子目录导入包

I'm new to go, so I hope this isn't perceived as dumb!

My current folder structure looks similar to this enter image description here

In the models folder, I have person.go.

package models

//Person struct
type Person struct {
    Name   string
    Age    int
    Gender string
}

In the main.go, I like to import models, so that I can use the person struct.

    package main

import "fmt"
import "models"

func main() {
    person = Person{Name: "Ali", Age: 34, Gender: "Male"}    
    fmt.Println("person is", person)
}

When I try execute go build, I get the following exception:

main.go:4:8: cannot find package "models" in any of: C:\Go\src\models (from $GOROOT) C:\Users\Ali\go\src\models (from $GOPATH)

I get that because my current working folder isn't my $GOROOT, nor is it the $GOPATH. In fact, I don't really want to add the models folder to either of those folders.

Is this even possible?

Use ./models instead of models.

But the better solution is using go project directory structure.

Read official docs