See https://golang.org/ref/spec#Import_declarations. By default importing a
package requires using the package name to refer to any symbols it exports;
e.g., "jsonstuff.Prices". You can do "import . jsonstuff" to allow
accessing its public symbols without qualification. Google "go import
unqualified" for some discussions about the pros and cons of unqualified
imports.

On Tue, Jul 28, 2020 at 7:48 PM jules <j.email.fie...@gmail.com> wrote:

> I'm new to golang and learning it in evenings with no one to ask questions
> of.   I have a local files:
>
> Here is  /home/jules/go/src/jsonstuff/typestuff.go :
> package jsonstuff
>
> type Prices struct {
>     BidPrice float64 `json:"p"`
> }
>
> --------------------------------------------------------
> Here is /home/jules/go/sampleproject/main.go
> package main
>
> import (
>         "fmt"
>         "jsonstuff"
> )
>
> func main() {
>         var price Prices
>         fmt.Println("Hello golang")
>         fmt.Println(price)
> }
> =====================================
>
> But I get the error:
> ~/go/sampleproject$ go run main.go
> # command-line-arguments
> ./main.go:5:2: imported and not used: "jsonstuff"
> ./main.go:13:12: undefined: Prices
>
> Why is it not picking up the type from the import file?
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/a3bdeaae-19b4-4a31-ad56-b5afe54d2185o%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/a3bdeaae-19b4-4a31-ad56-b5afe54d2185o%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CABx2%3DD_n75np05XVwyWBe8-LLL-3u0uy53SE8X9B%3DabMBM%2Bz%3Dw%40mail.gmail.com.

Reply via email to