1
0
mirror of https://github.com/fumiama/go-docx.git synced 2026-06-09 09:42:55 +08:00

feat: embed template xmls

This commit is contained in:
源文雨
2023-02-09 14:05:31 +08:00
parent 20d91d61a4
commit 2d8e706815
17 changed files with 481 additions and 429 deletions

View File

@@ -11,7 +11,7 @@ import (
var fileLocation *string
func init() {
fileLocation = flag.String("file", "/tmp/new-file.docx", "file location")
fileLocation = flag.String("file", "new-file.docx", "file location")
flag.Parse()
}
@@ -21,6 +21,7 @@ func main() {
if err != nil {
panic(err)
}
defer readFile.Close()
fileinfo, err := readFile.Stat()
if err != nil {
panic(err)

View File

@@ -11,7 +11,7 @@ import (
var fileLocation *string
func init() {
fileLocation = flag.String("file", "/tmp/new-file.docx", "file location")
fileLocation = flag.String("file", "new-file.docx", "file location")
flag.Parse()
}
func main() {
@@ -35,8 +35,14 @@ func main() {
if err != nil {
panic(err)
}
defer f.Close()
w.Write(f)
err = w.Write(f)
if err != nil {
panic(err)
}
err = f.Close()
if err != nil {
panic(err)
}
fmt.Println("Document writen. \nNow trying to read it")
// Now let's try to read the file
readFile, err := os.Open(*fileLocation)