Skip to content
This repository has been archived by the owner on Apr 8, 2021. It is now read-only.

Commit

Permalink
gofmt
Browse files Browse the repository at this point in the history
  • Loading branch information
tealeg committed Oct 10, 2019
1 parent d8bce4b commit d9a28ac
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 54 deletions.
68 changes: 34 additions & 34 deletions col_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestMakeWay(t *testing.T) {

// Col1: |--|
// Col2: |--|
assertWayMade([]*Col{&Col{Min: 1, Max: 2}, &Col{Min: 3, Max: 4}},
assertWayMade([]*Col{{Min: 1, Max: 2}, {Min: 3, Max: 4}},
func(cs *ColStore) {
c.Assert(cs.Len, qt.Equals, 2)
root := cs.Root
Expand All @@ -123,7 +123,7 @@ func TestMakeWay(t *testing.T) {

// Col1: |--|
// Col2: |--|
assertWayMade([]*Col{&Col{Min: 3, Max: 4}, &Col{Min: 1, Max: 2}},
assertWayMade([]*Col{{Min: 3, Max: 4}, {Min: 1, Max: 2}},
func(cs *ColStore) {
root := cs.Root
c.Assert(cs.Len, qt.Equals, 2)
Expand All @@ -140,7 +140,7 @@ func TestMakeWay(t *testing.T) {

// Col1: |--x|
// Col2: |--|
assertWayMade([]*Col{&Col{Min: 1, Max: 3}, &Col{Min: 3, Max: 4}},
assertWayMade([]*Col{{Min: 1, Max: 3}, {Min: 3, Max: 4}},
func(cs *ColStore) {
root := cs.Root
c.Assert(cs.Len, qt.Equals, 2)
Expand All @@ -157,7 +157,7 @@ func TestMakeWay(t *testing.T) {

// Col1: |x-|
// Col2: |--|
assertWayMade([]*Col{&Col{Min: 2, Max: 3}, &Col{Min: 1, Max: 2}},
assertWayMade([]*Col{{Min: 2, Max: 3}, {Min: 1, Max: 2}},
func(cs *ColStore) {
root := cs.Root
c.Assert(cs.Len, qt.Equals, 2)
Expand All @@ -174,7 +174,7 @@ func TestMakeWay(t *testing.T) {

// Col1: |---xx---|
// Col2: |--|
assertWayMade([]*Col{&Col{Min: 1, Max: 8}, &Col{Min: 4, Max: 5}},
assertWayMade([]*Col{{Min: 1, Max: 8}, {Min: 4, Max: 5}},
func(cs *ColStore) {
root := cs.Root
c.Assert(cs.Len, qt.Equals, 3)
Expand All @@ -196,7 +196,7 @@ func TestMakeWay(t *testing.T) {

// Col1: |xx|
// Col2: |--|
assertWayMade([]*Col{&Col{Min: 1, Max: 2, Width: 40.1}, &Col{Min: 1, Max: 2, Width: 10.0}},
assertWayMade([]*Col{{Min: 1, Max: 2, Width: 40.1}, {Min: 1, Max: 2, Width: 10.0}},
func(cs *ColStore) {
root := cs.Root
c.Assert(cs.Len, qt.Equals, 1)
Expand All @@ -211,7 +211,7 @@ func TestMakeWay(t *testing.T) {

// Col1: |xx|
// Col2: |----|
assertWayMade([]*Col{&Col{Min: 2, Max: 3, Width: 40.1}, &Col{Min: 1, Max: 4, Width: 10.0}},
assertWayMade([]*Col{{Min: 2, Max: 3, Width: 40.1}, {Min: 1, Max: 4, Width: 10.0}},
func(cs *ColStore) {
root := cs.Root
c.Assert(cs.Len, qt.Equals, 1)
Expand All @@ -226,7 +226,7 @@ func TestMakeWay(t *testing.T) {
// Col1: |--|
// Col2: |--|
// Col3: |--|
assertWayMade([]*Col{&Col{Min: 1, Max: 2}, &Col{Min: 3, Max: 4}, &Col{Min: 5, Max: 6}},
assertWayMade([]*Col{{Min: 1, Max: 2}, {Min: 3, Max: 4}, {Min: 5, Max: 6}},
func(cs *ColStore) {
root := cs.Root
c.Assert(cs.Len, qt.Equals, 3)
Expand All @@ -249,7 +249,7 @@ func TestMakeWay(t *testing.T) {
// Col1: |--|
// Col2: |--|
// Col3: |--|
assertWayMade([]*Col{&Col{Min: 5, Max: 6}, &Col{Min: 3, Max: 4}, &Col{Min: 1, Max: 2}},
assertWayMade([]*Col{{Min: 5, Max: 6}, {Min: 3, Max: 4}, {Min: 1, Max: 2}},
func(cs *ColStore) {
root := cs.Root
c.Assert(cs.Len, qt.Equals, 3)
Expand All @@ -272,7 +272,7 @@ func TestMakeWay(t *testing.T) {
// Col1: |--|
// Col2: |--|
// Col3: |--|
assertWayMade([]*Col{&Col{Min: 1, Max: 2}, &Col{Min: 10, Max: 11}, &Col{Min: 5, Max: 6}},
assertWayMade([]*Col{{Min: 1, Max: 2}, {Min: 10, Max: 11}, {Min: 5, Max: 6}},
func(cs *ColStore) {
root := cs.Root
c.Assert(cs.Len, qt.Equals, 3)
Expand All @@ -296,7 +296,7 @@ func TestMakeWay(t *testing.T) {
// Col2: |x-|
// Col3: |-------|
assertWayMade([]*Col{
&Col{Min: 1, Max: 2}, &Col{Min: 8, Max: 9}, &Col{Min: 2, Max: 8}},
{Min: 1, Max: 2}, {Min: 8, Max: 9}, {Min: 2, Max: 8}},
func(cs *ColStore) {
root := cs.Root
c.Assert(cs.Len, qt.Equals, 3)
Expand All @@ -320,7 +320,7 @@ func TestMakeWay(t *testing.T) {
// Col2: |--|
// Col3: |-----|
assertWayMade([]*Col{
&Col{Min: 1, Max: 2}, &Col{Min: 8, Max: 9}, &Col{Min: 2, Max: 7}},
{Min: 1, Max: 2}, {Min: 8, Max: 9}, {Min: 2, Max: 7}},
func(cs *ColStore) {
root := cs.Root
c.Assert(cs.Len, qt.Equals, 3)
Expand All @@ -344,7 +344,7 @@ func TestMakeWay(t *testing.T) {
// Col2: |x-|
// Col3: |-----|
assertWayMade([]*Col{
&Col{Min: 1, Max: 2}, &Col{Min: 8, Max: 9}, &Col{Min: 3, Max: 8}},
{Min: 1, Max: 2}, {Min: 8, Max: 9}, {Min: 3, Max: 8}},
func(cs *ColStore) {
root := cs.Root
c.Assert(cs.Len, qt.Equals, 3)
Expand All @@ -370,10 +370,10 @@ func TestMakeWay(t *testing.T) {
// Col4: |--|
assertWayMade(
[]*Col{
&Col{Min: 1, Max: 2},
&Col{Min: 3, Max: 4, Width: 1.0},
&Col{Min: 5, Max: 6},
&Col{Min: 3, Max: 4, Width: 2.0},
{Min: 1, Max: 2},
{Min: 3, Max: 4, Width: 1.0},
{Min: 5, Max: 6},
{Min: 3, Max: 4, Width: 2.0},
},
func(cs *ColStore) {
root := cs.Root
Expand Down Expand Up @@ -401,10 +401,10 @@ func TestMakeWay(t *testing.T) {
// Col4: |----|
assertWayMade(
[]*Col{
&Col{Min: 1, Max: 2, Width: 1.0},
&Col{Min: 3, Max: 4, Width: 2.0},
&Col{Min: 5, Max: 6, Width: 3.0},
&Col{Min: 2, Max: 5, Width: 4.0},
{Min: 1, Max: 2, Width: 1.0},
{Min: 3, Max: 4, Width: 2.0},
{Min: 5, Max: 6, Width: 3.0},
{Min: 2, Max: 5, Width: 4.0},
},
func(cs *ColStore) {
root := cs.Root
Expand Down Expand Up @@ -545,35 +545,35 @@ func (css *ColStoreSuite) TestGetOrMakeColsForRange(c *C) {
}

// make everything
assertCols(1, 11, nil, []*Col{&Col{Min: 1, Max: 11}})
assertCols(1, 11, nil, []*Col{{Min: 1, Max: 11}})

// get everything, one col
assertCols(1, 11, []*Col{&Col{Min: 1, Max: 11}}, []*Col{&Col{Min: 1, Max: 11}})
assertCols(1, 11, []*Col{{Min: 1, Max: 11}}, []*Col{{Min: 1, Max: 11}})

// get everything, many cols
assertCols(1, 11,
[]*Col{
&Col{Min: 1, Max: 4},
&Col{Min: 5, Max: 8},
&Col{Min: 9, Max: 11},
{Min: 1, Max: 4},
{Min: 5, Max: 8},
{Min: 9, Max: 11},
},
[]*Col{
&Col{Min: 1, Max: 4},
&Col{Min: 5, Max: 8},
&Col{Min: 9, Max: 11},
{Min: 1, Max: 4},
{Min: 5, Max: 8},
{Min: 9, Max: 11},
},
)

// make missing col
assertCols(1, 11,
[]*Col{
&Col{Min: 1, Max: 4},
&Col{Min: 9, Max: 11},
{Min: 1, Max: 4},
{Min: 9, Max: 11},
},
[]*Col{
&Col{Min: 1, Max: 4},
&Col{Min: 5, Max: 8},
&Col{Min: 9, Max: 11},
{Min: 1, Max: 4},
{Min: 5, Max: 8},
{Min: 9, Max: 11},
},
)

Expand Down
16 changes: 8 additions & 8 deletions date.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
)

const (
MJD_0 float64 = 2400000.5
MJD_0 float64 = 2400000.5
MJD_JD2000 float64 = 51544.5

secondsInADay = float64((24*time.Hour)/time.Second)
nanosInADay = float64((24*time.Hour)/time.Nanosecond)
secondsInADay = float64((24 * time.Hour) / time.Second)
nanosInADay = float64((24 * time.Hour) / time.Nanosecond)
)

var (
Expand All @@ -25,8 +25,8 @@ var (
excel1900Epoc = time.Date(1899, time.December, 30, 0, 0, 0, 0, time.UTC)
excel1904Epoc = time.Date(1904, time.January, 1, 0, 0, 0, 0, time.UTC)
// Days between epocs, including both off by one errors for 1900.
daysBetween1970And1900 = float64(unixEpoc.Sub(excel1900Epoc)/(24 * time.Hour))
daysBetween1970And1904 = float64(unixEpoc.Sub(excel1904Epoc)/(24 * time.Hour))
daysBetween1970And1900 = float64(unixEpoc.Sub(excel1900Epoc) / (24 * time.Hour))
daysBetween1970And1904 = float64(unixEpoc.Sub(excel1904Epoc) / (24 * time.Hour))
)

func TimeToUTCTime(t time.Time) time.Time {
Expand Down Expand Up @@ -124,17 +124,17 @@ func TimeFromExcelTime(excelTime float64, date1904 bool) time.Time {
date = excel1900Epoc
}
durationPart := time.Duration(nanosInADay * floatPart)
return date.AddDate(0,0, wholeDaysPart).Add(durationPart)
return date.AddDate(0, 0, wholeDaysPart).Add(durationPart)
}

// TimeToExcelTime will convert a time.Time into Excel's float representation, in either 1900 or 1904
// mode. If you don't know which to use, set date1904 to false.
// TODO should this should handle Julian dates?
func TimeToExcelTime(t time.Time, date1904 bool) float64 {
// Get the number of days since the unix epoc
daysSinceUnixEpoc := float64(t.Unix())/secondsInADay
daysSinceUnixEpoc := float64(t.Unix()) / secondsInADay
// Get the number of nanoseconds in days since Unix() is in seconds.
nanosPart := float64(t.Nanosecond())/nanosInADay
nanosPart := float64(t.Nanosecond()) / nanosInADay
// Add both together plus the number of days difference between unix and Excel epocs.
var offsetDays float64
if date1904 {
Expand Down
4 changes: 2 additions & 2 deletions stream_file_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func (sb *StreamFileBuilder) Build() (*StreamFile, error) {

func (sb *StreamFileBuilder) marshalStyles() (string, error) {

for streamStyle, _ := range sb.customStreamStyles {
for streamStyle := range sb.customStreamStyles {
XfId := handleStyleForXLSX(streamStyle.style, streamStyle.xNumFmtId, sb.xlsxFile.styles)
sb.styleIdMap[streamStyle] = XfId
}
Expand Down Expand Up @@ -390,7 +390,7 @@ func getSheetIndex(sf *StreamFile, path string) (int, error) {
func removeDimensionTag(data string) string {
start := strings.Index(data, "<dimension")
end := strings.Index(data, "</dimension>") + 12
return data[0:start] + data[end:len(data)]
return data[0:start] + data[end:]
}

// splitSheetIntoPrefixAndSuffix will split the provided XML sheet into a prefix and a suffix so that
Expand Down
18 changes: 9 additions & 9 deletions stream_style_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ func TestXlsxStreamWriteWithStyle(t *testing.T) {
}

expectedWorkbookDataStrings := [][][]string{}
for j, _ := range testCase.workbookData {
for j := range testCase.workbookData {
expectedWorkbookDataStrings = append(expectedWorkbookDataStrings, [][]string{})
for k, _ := range testCase.workbookData[j] {
for k := range testCase.workbookData[j] {
if len(testCase.workbookData[j][k]) == 0 {
expectedWorkbookDataStrings[j] = append(expectedWorkbookDataStrings[j], nil)
} else {
Expand Down Expand Up @@ -467,7 +467,7 @@ func TestStreamStyleDates(t *testing.T) {
}

expectedWorkbookDataStrings := [][][]string{}
for j, _ := range workbookData {
for j := range workbookData {
expectedWorkbookDataStrings = append(expectedWorkbookDataStrings, [][]string{})
for range workbookData[j] {
expectedWorkbookDataStrings[j] = append(expectedWorkbookDataStrings[j], []string{})
Expand Down Expand Up @@ -552,9 +552,9 @@ func TestMakeNewStylesAndUseIt(t *testing.T) {
}

expectedWorkbookDataStrings := [][][]string{}
for j, _ := range workbookData {
for j := range workbookData {
expectedWorkbookDataStrings = append(expectedWorkbookDataStrings, [][]string{})
for k, _ := range workbookData[j] {
for k := range workbookData[j] {
expectedWorkbookDataStrings[j] = append(expectedWorkbookDataStrings[j], []string{})
for _, cell := range workbookData[j][k] {
expectedWorkbookDataStrings[j][k] = append(expectedWorkbookDataStrings[j][k], cell.cellData)
Expand Down Expand Up @@ -607,9 +607,9 @@ func TestStreamNewTypes(t *testing.T) {
}

expectedWorkbookDataStrings := [][][]string{}
for j, _ := range workbookData {
for j := range workbookData {
expectedWorkbookDataStrings = append(expectedWorkbookDataStrings, [][]string{})
for k, _ := range workbookData[j] {
for k := range workbookData[j] {
expectedWorkbookDataStrings[j] = append(expectedWorkbookDataStrings[j], []string{})
for _, cell := range workbookData[j][k] {
if cell.cellData == "1" {
Expand Down Expand Up @@ -794,8 +794,8 @@ func TestStreamNoStylesWriteSError(t *testing.T) {
}

func checkForCorrectCellStyles(actualCells [][][]Cell, expectedCells [][][]StreamCell) error {
for i, _ := range actualCells {
for j, _ := range actualCells[i] {
for i := range actualCells {
for j := range actualCells[i] {
for k, actualCell := range actualCells[i][j] {
expectedCell := expectedCells[i][j][k]
if err := compareCellStyles(actualCell, expectedCell); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion write.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (r *Row) WriteSlice(e interface{}, cols int) int {
case fmt.Stringer: // check Stringer first
cell := r.AddCell()
cell.SetString(t.String())
case sql.NullString: // check null sql types nulls = ''
case sql.NullString: // check null sql types nulls = ''
cell := r.AddCell()
if cell.SetString(``); t.Valid {
cell.SetValue(t.String)
Expand Down

0 comments on commit d9a28ac

Please sign in to comment.