What is err.(*os.PathError) in Go?

后端 未结 2 606
有刺的猬
有刺的猬 2020-12-31 14:04

When I was reading: http://golang.org/doc/effective_go.html#errors

I found such line: err.(*os.PathError) in this context:

for try := 0;         


        
2条回答
  •  离开以前
    2020-12-31 14:23

    From the docs, that is a type assertion:

    For an expression x of interface type and a type T, the primary expression

     x.(T)
    

    asserts that x is not nil and that the value stored in x is of type T. The notation x.(T) is called a type assertion.

提交回复
热议问题