File written to by the program not saving occasionally
h
Baconman321 (1103)

I have a program in Go that allows me to make and edit articles.

Sometimes, though the program won't save an edit of the article. The articles are stored via a .json file.

I have noticed that this usually happens if I close out of the window after it says it has successfully been edited, OR I close out of the computer. It always saves if I open the repl and check if it has been saved (as far as I know).

@tussiez told me that it was simply replit not saving sometimes, but I start to doubt that. It shows the edited article, but if I come back the next day the new edit is gone! It must be deleting the contents of the edit, but why? Also, how would I fix this?

Help would be appreciated.

- A confused bacon

You are viewing a single comment. View All
robowolf (550)

Well sometimes if you haven't closed the file, for example when you do something like files = open('file',w) and forget to do files.close() it doesn't save. Also could you put your code, and when it say it's been edited has the file actually been edited.

Baconman321 (1103)

@robowolf Yeah, but AFAIK ioutil.WriteFile doesn't have a close method :/

I think the method I use already closes it for me when it's done.

My friend did recommend to me that I should check if the contents of the file are edited. I just want to know what is going on...

It saves but the next day it is gone!

>:/

robowolf (550)

@Baconman321 Could you post your code?

Baconman321 (1103)

@robowolf Example:

ioutil.WriteFile([]byte("hello, world"), "testFile.txt", 0644)
Andy_4sberg (54)

@Baconman321, does the language your programming this in support Replit's database?

robowolf (550)

@Baconman321 Well if your working with json why not just use the default json methods. Also try on another repl, sometimes if a repl is buggy for me when I open a new one it works.

Baconman321 (1103)

@Andy_4sberg Yeah, Go supports DB functions, but I don't want to use it rn.

replit's database isn't as good as file storage IMO, except for the fact that it actually saves the content.

If replit DB got much better (increased key name range and more storage size), then yes I think I'd use it.