Hello! I'll try my best to make this issue the last one, so I won't litter issues with my questions that much. Thanks for the help in advance!!!
code:
readFile, err := os.Open(filename)
if err != nil {
slog.Error("error while oppening docx file", "unit_guid", devInfo.UnitGuid, "err", err)
}
fileinfo, err := readFile.Stat()
if err != nil {
slog.Error("error while reading docx file stat file", "unit_guid", devInfo.UnitGuid, "err", err)
}
size := fileinfo.Size()
oldDoc, err := docx.Parse(readFile, size)
if err != nil {
slog.Error("error while parsing docx file", "unit_guid", devInfo.UnitGuid, "err", err)
}
newDoc := docx.NewA4()
p := newDoc.AddParagraph()
p.AddText(text).Size("10")
// ADD OLD FILE CONTENT HERE
newDoc.AppendFile(oldDoc)
if err != nil {
slog.Error("error while creating file", "unit_guid", devInfo.UnitGuid, "err", err)
}
_, err = newDoc.WriteTo(readFile)
if err != nil {
slog.Error("error while writing file", "unit_guid", devInfo.UnitGuid, "err", err)
}
err = readFile.Close()
if err != nil {
slog.Error("error while saving file", "unit_guid", devInfo.UnitGuid, "err", err)
}
this whole block of code is executed about 3-4 times, and should add one line to the file at a time
however, after the program exits, the created file has only one out of 3-4 lines it should
I tried literally everything at this point, but still cant get it to work...