2017-09-04 3 views
-1
Mein GOPATH und GOROOT
GOPATH="/Users/road/IdeaProjects/MiniJVM" 
GOROOT="/usr/local/go" 
Meine golang Projektstruktur
Myproject 
---.idea 
---src 
    ---cmd 
     ---cmd.go 
    ---test 
     ---test.go 
test.go Datei, werde ich die Einfuhren aus anderen Paketen nutzen .Was mit meinem Code falsch? Oder der Importpfad hat ein Problem?
package main 

import (
    "fmt" 
    "cmd" 
) 
func main() { 
    command := &Cmd{}//unresolved type 'Cmd' 
} 
cmd.go Datei
package cmd 

import (
    "flag" 
    "fmt" 
    "os" 
) 

/* 
    jaca [-option] class [args...] 
*/ 
type Cmd struct { 
    HelpFlag bool 
    VersionFlag bool 
    CpOption string 
    Class string 
    Args []string 
} 

Antwort

1

Sie können den Ordnernamen "cmd" anderen Namen ändern, weil es bereits ein Paket "cmd" ist in die Standardbibliothek.

1

Verwenden Sie den vollständigen Pfad:

import (
    "github.com/myname/myproject/src/cmd" 
) 
Verwandte Themen