Referencing a type from another package must specify what package it comes 
from. Try:


var a *common.Any


Also, I would avoid using the term "alias" here. Type aliasing in go is 
totally different from defining a new type, which is what you do here. Type 
aliasing takes the form:

type T1 = T2

Type aliasing was only recently introduced to the language, and intended 
for very specific cases. So I would avoid using it without fully 
understanding the ramifications. 

- Jake


On Saturday, February 3, 2018 at 11:45:22 AM UTC-5, l vic wrote:
>
> I am trying to alias empty interface in one package so it could be used in 
> several other packages:
> in "myproject/common/common.go"
>
> package common
>
> type Any interface{}
>
>
> But when i try to use it from another package "myproject/myutil/myutil.go"
>
> *package myutil*
>
> *import (*
>
> *"*myproject/common"
>
> )
>
> var a *Any
>
>
> I have compilation error:
>
> imported and not used: "myproject/common" 
>
> undefined: Any
>
>
> I declared type Any with capital 'A', so it's supposed to be visible from 
> other packages... Where's the error?
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to