Pergunta

 11 func Map(value string) *list.List {
 12 }

for example as above. "list" is var name, List is goLang built-in type. how do I understand *list.List ?

Is it a List pointer that with name list?

Also, if my understanding is right, what is the element's type in this list? It is not defined.

Thanks,

Foi útil?

Solução

The Go Programming Language Specification

Function types

A function type denotes the set of all functions with the same parameter and result types. The value of an uninitialized variable of function type is nil.

FunctionType   = "func" Signature .
Signature      = Parameters [ Result ] .
Result         = Parameters | Type .
Parameters     = "(" [ ParameterList [ "," ] ] ")" .
ParameterList  = ParameterDecl { "," ParameterDecl } .
ParameterDecl  = [ IdentifierList ] [ "..." ] Type .

Within a list of parameters or results, the names (IdentifierList) must either all be present or all be absent. If present, each name stands for one item (parameter or result) of the specified type and all non-blank names in the signature must be unique. If absent, each type stands for one item of that type. Parameter and result lists are always parenthesized except that if there is exactly one unnamed result it may be written as an unparenthesized type.


Package list

import "container/list"

Package list implements a doubly linked list.

type Element

type Element struct {

        // The value stored with this element.
        Value interface{}
        // contains filtered or unexported fields
}

Element is an element of a linked list.

type List

type List struct {
        // contains filtered or unexported fields
}

List represents a doubly linked list. The zero value for List is an empty list ready to use.


list is a package name. The result type *list.List is a pointer to type list.List. The elements of type list.List are of type list.Element. For example,

package main

import "container/list"

func Map(value string) *list.List { return nil }

func main() {}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top