RockNinja
RockNinja

Reputation: 2309

Package imports

I have one package called model and two files which both are using the model package (user.go, task.go).

My question: In both files I am importing the appengine and appengine\datasotre libs, do I need to do so?, or there is a better way of doing this?

user.go

package model

import "appengine"
import "appengine/datastore"


type User struct {
  name
}
func (u *User) Save(c appengine.Context) (*User, error){
}

task.go

package model
import "appengine"
import "appengine/datastore"

type Task struct {
  name
}

func (u *Task) Save(c appengine.Context) (*Task, error){
}

Upvotes: 1

Views: 71

Answers (1)

Toni Cárdenas
Toni Cárdenas

Reputation: 6820

Yes. Imports work per file, not per package.

I recommend installing goimports to handle imports for you.

Upvotes: 3

Related Questions