2021年4月5日星期一

Is there anyway for return value if not null in struct of Golang model?

I've just learned about Golang and its framework is gorm I declare a model that have about 7 columns... But when I query I only need 5 column to return an api for browser... So what can I do to return a array of struct with exclude 2 others unuse column like this:

type user struct{  id  username  email  password  fullname  phone  avatar  }  

but I only need to return in a api that exclude password and user using that user struct(query to an array of that struct). How can I do that?

https://stackoverflow.com/questions/66962978/is-there-anyway-for-return-value-if-not-null-in-struct-of-golang-model April 06, 2021 at 01:06PM

没有评论:

发表评论