我是新来的 Stack Overflow,这是我的第一个问题,所以我非常开放并乐意对其进行任何改进:)当我运行与艺术品不同的测试方法时遇到问题。我有一种方法可以让用户喜欢按他们自己单独的艺术品 uuid 分类的特定艺术品,并且该方法效果很好。我有一个 console.proto 文件,在其中为 LikeArtwork 和 LikeArtwork 方法指定必要的请求和响应消息,并在methods.go 文件中创建了这些方法本身。我正在测试其他方法,除了 LikeArtwork 方法之外,它们似乎都工作得很好。
我有一个 followUser 和 UnfollowUser 方法,它们的工作方式完全相同,除了在 UnfollowUser 方法中,用户只是从包含所有关注者的“关注者”切片/数组中删除。这个概念与 likeArtwork 和 LikeArtwork 方法完全相同,其中用户从“喜欢”切片/数组中添加或删除,这就是为什么我很困惑为什么它会导致我的用户服务器因错误而崩溃:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x58 pc=0x104d0b844]
Run Code Online (Sandbox Code Playgroud)
我的console.proto定义如下:
service Service {
// Registers a user on the hockney platform/ This entails creating the user
// using the CreateUser method and uploading their profile picture using the
// UploadProfilePicture method/ Down the line, this could also …Run Code Online (Sandbox Code Playgroud)