Hi, i have an issue. I am learning go and trying to create a hostel API. But each time I use postman , I keep getting only the id value the rest don’t come out. I will like to know the error I am making Here is a screenshot of my problem
Can we see the code that responds to that API request?
Go doesn’t use keywords like
private to distinguish accessibility of identifiers (fields, functions, types, etc); uppercase names are public and lowercase are private. The issue is your fields all start with lowercase names, so the
json package cannot see any of them except for the
ID field. Rename your fields so they start with uppercase letters.
thank you so very much
hi, Do you have any idea why this does not return a list of all students?
Did you ask for students?
log.Fatal(err) unconditionally. And assuming you use the go standard libraries
log package, this means exiting your program unconditionally.
This is my log error
In your screenshot, you’re calling
log.Fatal(err), not your
log.Fatal will abort the goroutine when it’s called so your rows are never scanned.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.