Wednesday, March 22, 2023
HomeGolangNot able to append/overwrite JSON documents (Go) - Obtaining Assistance

Not able to append/overwrite JSON documents (Go) – Obtaining Assistance

Excellent day everybody, I am a novice to Go as well as am still finding out the ropes, presently I am dealing with problems while making adjustments to a json documents.

So I have a feature that generally eliminates a component from the piece. I am incapable to add the json documents in other places other than at one place. The “Done” will constantly obtain published, any type of ideas on this? Thanks :slight_smile:

 func removeAppt( eliminate AppointmentsDetail) {
bookedAppointmentsData:= getBookedAppointmentsData()// Obtain the piece of information

for i:= 0; i < < len( bookedAppointmentsData); i++ {
bookedAppt:= bookedAppointmentsData[i]
// If suits input worth eliminates it from piece as well as append to json.
if bookedAppt == eliminate {
bookedAppointmentsData = append( bookedAppointmentsData[:i], bookedAppointmentsData[i+1:] ...).

bytes, err:= json.MarshalIndent( bookedAppointmentsData, ""," ").

if err!= nil {
log.Fatalln( err).

_ = ioutil.WriteFile(" bookedAppointments.json", bytes, 0644).

fmt.println(" Done")// Constantly obtains published.




Most Popular

Recent Comments