Back

GoLang SDK - Need help querying with listDocuments

  • 1
  • Databases
Vex
12 Feb, 2025, 13:15

Hey i am getting this error when i try to run my golang code i been looking for a solution for a while so i come here, here is the full error i am fairly new to goland so sorry if im being stupid :

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

goroutine 1 [running]: github.com/appwrite/sdk-for-go/models.(*DocumentList).Decode(0xc0003ffe98?, {0x6db5e0?, 0xc000191ea0?}) /home/vex/go/pkg/mod/github.com/appwrite/sdk-for-go@v0.3.0/models/documentlist.go:25 +0x1c main.getTransactions(0xc0003ffe98) /home/vex//d/main.go:68 +0x13a main.main() /home/vex///main.go:40 +0x225 exit status 2

And here is a snippet of my code

TL;DR
Developers experiencing a segmentation violation issue when trying to run GoLang SDK code. The error is caused by an invalid memory address or nil pointer dereference. The problematic line seems to be the `res, := appwriteDatabases.ListDocuments()` call. To solve this problem, ensure that the `res` variable is properly initialized before passing it into `appwriteDatabases.ListDocuments()`.
Vex
12 Feb, 2025, 13:15
TypeScript
func getDatabaseInfo(appwriteDatabases *databases.Databases) {
  res,  := appwriteDatabases.ListDocuments(
        "databaseId", /* Both this and the collectionId below are set to valid values in the codebase */
        "collectionId", /* Same here */

        appwriteDatabases.WithListDocumentsQueries(
            []string{
                query.NotEqual("Complete", true),
            },
        ),
    )

}
Santander
12 Feb, 2025, 13:58

@Guille

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more