-
Notifications
You must be signed in to change notification settings - Fork 1
/
sample.go
79 lines (68 loc) · 1.57 KB
/
sample.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package main
import (
"bufio"
"fmt"
"log"
"os"
"strings"
)
func YnPrompt(label string, def bool) bool {
choices := "Y/n"
if !def {
choices = "y/N"
}
r := bufio.NewReader(os.Stdin)
var s string
for {
fmt.Fprintf(os.Stderr, "%s (%s) ", label, choices)
s, _ = r.ReadString('\n')
s = strings.TrimSpace(s)
if s == "" {
return def
}
s = strings.ToLower(s)
if s == "y" || s == "yes" {
return true
}
if s == "n" || s == "no" {
return false
}
}
}
func createTOML() {
f, err := os.Create("invoice-generator.toml")
if err != nil {
log.Fatal(err)
}
defer f.Close()
_, err = f.WriteString(TemplateTOML)
if err != nil {
log.Fatal(err)
}
fmt.Println("invoice-generator.toml created!")
}
var TemplateTOML = `# Invoice data with SE-DDMMYY number and due date +10 days
Fullname = "Bob Sanders"
MyAddress = """Lorem ipsum amet, 221, 42
Aenean ligula, 129104 City, Country."""
MyEmail = "[email protected]"
TaxId = "400424221"
InvoiceTo = "World JSC"
CompanyAddress = """
c/o Alice Henderson
Nam quam nunc, blandit vel 11
Sed fringilla mauris, 68
409118, Middle-earth"""
ServiceDescription = "Backend development services for the period of {xx.xx.xxxx} to {yy.yy.yyyy}"
Price = 1500
Currency = "USD"
Quantity = 2
VAT = 10
PaymentDetails = "Please transfer the due amount according to the following payment details."
BeneficiaryName = "IE Bob Sanders"
BeneficiaryAddress = "FARFROMPOOPEN ROAD TURN 5, CITY, COUNTRY"
BankName = "Bank of the Middle-earth"
BankAddress = "42c GAGARIN STREET, Mars 0160, Middle-earth"
IBAN = "XXXXLX11100003168990YY"
SwiftBIC = "XXXXXX11"
`