num: add field names to Go syntax printing of types
MODIFY
num/dual/dual.go
num/dual/dual.go
@@ -30,7 +30,7 @@ func (d Number) Format(fs fmt.State, c rune) {
switch c {
case 'v':
if fs.Flag('#') {
- fmt.Fprintf(fs, "%T{%#v, %#v}", d, d.Real, d.Emag)
+ fmt.Fprintf(fs, "%T{Real:%#v, Emag:%#v}", d, d.Real, d.Emag)
return
}
c = 'g'

MODIFY
num/dualquat/dual.go
num/dualquat/dual.go
@@ -37,7 +37,7 @@ func (d Number) Format(fs fmt.State, c rune) {
switch c {
case 'v':
if fs.Flag('#') {
- fmt.Fprintf(fs, "%T{%#v, %#v}", d, d.Real, d.Dual)
+ fmt.Fprintf(fs, "%T{Real:%#v, Dual:%#v}", d, d.Real, d.Dual)
return
}
c = 'g'

MODIFY
num/hyperdual/hyperdual.go
num/hyperdual/hyperdual.go
@@ -33,7 +33,7 @@ func (d Number) Format(fs fmt.State, c rune) {
switch c {
case 'v':
if fs.Flag('#') {
- fmt.Fprintf(fs, "%T{%#v, %#v, %#v, %#v}", d, d.Real, d.E1mag, d.E2mag, d.E1E2mag)
+ fmt.Fprintf(fs, "%T{Real:%#v, E1mag:%#v, E2mag:%#v, E1E2mag%#v}", d, d.Real, d.E1mag, d.E2mag, d.E1E2mag)
return
}
c = 'g'

MODIFY
num/quat/quat.go
num/quat/quat.go
@@ -31,7 +31,7 @@ func (q Number) Format(fs fmt.State, c rune) {
switch c {
case 'v':
if fs.Flag('#') {
- fmt.Fprintf(fs, "%T{%#v, %#v, %#v, %#v}", q, q.Real, q.Imag, q.Jmag, q.Kmag)
+ fmt.Fprintf(fs, "%T{Real:%#v, Imag:%#v, Jmag:%#v, Kmag:%#v}", q, q.Real, q.Imag, q.Jmag, q.Kmag)
return
}
c = 'g'

MODIFY
num/quat/quat_test.go
num/quat/quat_test.go
@@ -94,8 +94,8 @@ var formatTests = []struct {
format string
want string
}{
- {q: Number{1.1, 2.1, 3.1, 4.1}, format: "%#v", want: "quat.Number{1.1, 2.1, 3.1, 4.1}"}, // Bootstrap test.
- {q: Number{-1.1, -2.1, -3.1, -4.1}, format: "%#v", want: "quat.Number{-1.1, -2.1, -3.1, -4.1}"}, // Bootstrap test.
+ {q: Number{1.1, 2.1, 3.1, 4.1}, format: "%#v", want: "quat.Number{Real:1.1, Imag:2.1, Jmag:3.1, Kmag:4.1}"}, // Bootstrap test.
+ {q: Number{-1.1, -2.1, -3.1, -4.1}, format: "%#v", want: "quat.Number{Real:-1.1, Imag:-2.1, Jmag:-3.1, Kmag:-4.1}"}, // Bootstrap test.
{q: Number{1, 2, 3, 4}, format: "%v", want: "(1+2i+3j+4k)"},
{q: Number{-1, -2, -3, -4}, format: "%v", want: "(-1-2i-3j-4k)"},
{q: Number{1, 2, 3, 4}, format: "%g", want: "(1+2i+3j+4k)"},

num: add field names to Go syntax printing of types