> ## Content Index
> Fetch the complete content index at: https://blog.hacking.pub/llms.txt
> Use this file to discover other available public pages before exploring further.

# go 成员方法
- URL: https://blog.hacking.pub/2019/10/21/untitled-5/
- Published: 2019-10-21T06:02:03.000Z
- Updated: 2019-10-21T06:02:20.000Z
- Author: chainhelen
- Tags: go, go语言, golang, 成员方法

被虐了，原来go里面的`nil`可以调用方法，但是成员变量会`panic`  
[https://github.com/go-delve/delve/pull/1722#discussion\_r336509209](https://github.com/go-delve/delve/pull/1722?ref=blog.hacking.pub#discussion%5Fr336509209)

```
package main

import (
	"fmt"
)

type Blah struct {
}

func (b *Blah) Foo() {
	fmt.Printf("hello!\n")
}

func main() {
	var b *Blah = nil
	b.Foo()
}

```