小编use*_*949的帖子

golang如何使用指针打印结构值

package main

import "fmt"

type A struct {
    a int32
    B *B
}
type B struct {
    b int32
}

func main() {
    a := &A{
        a: 1,
        B: &B{
            b: 2,
        },
    }
    fmt.Printf("v ==== %+v \n", a)
}


//ret: v ==== &{a:1 B:0xc42000e204}
//??? how to print B's content but not pointer
Run Code Online (Sandbox Code Playgroud)

printing struct pointers go

5
推荐指数
3
解决办法
8473
查看次数

标签 统计

go ×1

pointers ×1

printing ×1

struct ×1