1
0
mirror of https://github.com/fumiama/go-docx.git synced 2026-06-22 03:20:35 +08:00

Keep unmarshalling

This commit is contained in:
Gonzalo Fernandez-Victorio
2021-05-11 16:17:06 +01:00
parent af18d96b6b
commit 965e28ba05
4 changed files with 89 additions and 9 deletions

View File

@@ -1,16 +1,21 @@
package main
import (
"flag"
"fmt"
"os"
"github.com/gonfva/docxlib"
)
const FILE_PATH = "/tmp/new-file.docx"
var fileLocation *string
func init() {
fileLocation = flag.String("file", "/tmp/new-file.docx", "file location")
flag.Parse()
}
func main() {
fmt.Printf("Preparing new document to write at %s\n", FILE_PATH)
fmt.Printf("Preparing new document to write at %s\n", *fileLocation)
w := docxlib.New()
// add new paragraph
@@ -26,7 +31,7 @@ func main() {
nextPara := w.AddParagraph()
nextPara.AddLink("google", `http://google.com`)
f, err := os.Create(FILE_PATH)
f, err := os.Create(*fileLocation)
if err != nil {
panic(err)
}
@@ -34,7 +39,7 @@ func main() {
w.Write(f)
fmt.Println("Document writen. \nNow trying to read it")
// Now let's try to read the file
readFile, err := os.Open(FILE_PATH)
readFile, err := os.Open(*fileLocation)
if err != nil {
panic(err)
}