func docWriter(pdf *gofpdf.Fpdf, idx int) *pdfWriter { pw := new(pdfWriter) pw.pdf = pdf pw.idx = idx if pdf.Ok() { var err error fileStr := fmt.Sprintf("%s/pdf/tutorial%02d.pdf", cnGofpdfDir, idx) pw.fl, err = os.Create(fileStr) if err != nil { pdf.SetErrorf("Error opening output file %s", fileStr) } } return pw }
func tutorialSummary(f *gofpdf.Fpdf, fileStr string) { if f.Ok() { fl, err := os.Create(fileStr) defer fl.Close() if err == nil { f.Output(fl) } else { f.SetError(err) } } if f.Ok() { fmt.Printf("Successfully generated %s\n", fileStr) } else { errPrintf("%s\n", f.Error()) } }
func docWriter(pdf *gofpdf.Fpdf, idx int) *pdfWriter { pw := new(pdfWriter) pw.pdf = pdf pw.idx = idx if pdf.Ok() { var err error fileStr := fmt.Sprintf("%s\\test_pdf_%02d.pdf", cnGofpdfDir, idx) pw.fl, err = os.Create(fileStr) if err != nil { pdf.SetErrorf("Error opening output file %s", fileStr) } } fileLock1 := Locker{false, "lock#1"} printIsLocked(fileLock1) fileLock1.locked = true printIsLocked(fileLock1) fileLock2 := Locker{true, "lock#2"} printIsLocked(fileLock2) return pw }