gpt4 book ai didi

go - 是什么原因导致 "panic: runtime error: invalid memory address or nil pointer dereference"?

转载 作者:数据小太阳 更新时间:2023-10-29 03:44:12 32 4
gpt4 key购买 nike

<分区>

我的项目有问题。

出现错误:

panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x44c16f]

我做错了什么?

套餐A

package a

import (
"fmt"

"github.com/lathrel/test/b"

)

type (
// App ...
App b.App
)

// Fine is a fine :) but was fine :/
func (app *App) Fine(str string) string {
fmt.Println(str)
return ""
}

套餐 B

package b

// App is a test
type App struct {
fine Controller
}

// Controller is a test
type Controller interface {
Fine(str string) string
}

// InitB inits B :)
func InitB() {
app := App{}

app.fine.Fine("hi")
}

ma​​in.go

package main

import (
"github.com/lathrel/test/b"
)

func main() {
b.InitB()
}

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com