Skip to content

Commit

Permalink
Merge pull request #67 from webability-go/late-night
Browse files Browse the repository at this point in the history
Late night
  • Loading branch information
metalwolf committed Sep 2, 2022
2 parents 076bdd1 + d68ff73 commit 715208f
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 9 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@UTF-8

[![Go Report Card](https://goreportcard.com/badge/github.com/webability-go/xcore)](https://goreportcard.com/report/github.com/webability-go/xcore)
[![GoDoc](https://godoc.org/github.com/webability-go/xcore/v2?status.png)](https://godoc.org/github.com/webability-go/xcore/v2)
[![GolangCI](https://golangci.com/badges/github.com/webability-go/xcore.svg)](https://golangci.com)
Expand Down Expand Up @@ -28,6 +26,11 @@ Version Changes Control

# Please use xcore/v2

v1.1.1 - 2020-09-02
-----------------------
- Bug corrected on XDataset.GetString() and XDatasetCollection.GetDataString().
If the value is NIL int the dataset, it returns now "" and not "<nil>"

v1.1.0 - 2020-03-01
-----------------------
- Modularization of XCore
Expand Down
5 changes: 5 additions & 0 deletions v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ Some improvements to check, later:
Version Changes Control
=======================

v2.1.3 - 2022-09-02
-----------------------
- Bug corrected on XDataset.GetString() and XDatasetCollection.GetDataString().
If the value is NIL int the dataset, it returns now "" and not "<nil>"

v2.1.2 - 2022-03-02
-----------------------
- XTemplate: Added = to metalanguage string tags to resolve also the paths (bug corrected).
Expand Down
2 changes: 1 addition & 1 deletion v2/xcore.go
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@
package xcore

// VERSION is the used version nombre of the XCore library.
const VERSION = "2.1.2"
const VERSION = "2.1.3"

// LOG is the flag to activate logging on the library.
// if LOG is set to TRUE, LOG indicates to the XCore libraries to log a trace of functions called, with most important parameters.
Expand Down
3 changes: 3 additions & 0 deletions v2/xdataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ func (d *XDataset) GetCollection(key string) (XDatasetCollectionDef, bool) {
// GetString will read the value of the key variable as a string cast type
func (d *XDataset) GetString(key string) (string, bool) {
if val, ok := d.Get(key); ok {
if val == nil {
return "", true
}
return fmt.Sprint(val), true
}
return "", false
Expand Down
8 changes: 5 additions & 3 deletions v2/xdatasetcollection.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ func (d *XDatasetCollection) GetData(key string) (interface{}, bool) {

// GetDataString will retrieve the first available data identified by key from the collection ordered by index and return it as a string
func (d *XDatasetCollection) GetDataString(key string) (string, bool) {
v, ok := d.GetData(key)
if ok {
return fmt.Sprint(v), true
if val, ok := d.GetData(key); ok {
if val == nil {
return "", true
}
return fmt.Sprint(val), true
}
return "", false
}
Expand Down
2 changes: 2 additions & 0 deletions v2/xtemplate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ func TestXTemplateSimple(t *testing.T) {
&XDataset{"name": "other 2", "sport": "no"},
&XDataset{"name": "other 3", "sport": "yes"},
&XDataset{"name": "other 4", "sport": "no"},
&XDataset{"name": "other 5", "sport": nil},
},
"preferredhobby": &XDataset{
"name": "Baseball",
Expand Down Expand Up @@ -211,6 +212,7 @@ func TestXTemplateClone(t *testing.T) {
&XDataset{"name": "other 2", "sport": "no"},
&XDataset{"name": "other 3", "sport": "yes"},
&XDataset{"name": "other 4", "sport": "no"},
&XDataset{"name": "other 5", "sport": nil},
},
"preferredhobby": &XDataset{
"name": "Baseball",
Expand Down
2 changes: 1 addition & 1 deletion xcore.go
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@
package xcore

// VERSION is the used version nombre of the XCore library.
const VERSION = "1.1.0"
const VERSION = "1.1.1"

// LOG is the flag to activate logging on the library.
// if LOG is set to TRUE, LOG indicates to the XCore libraries to log a trace of functions called, with most important parameters.
Expand Down
6 changes: 6 additions & 0 deletions xdataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ func (d *XDataset) GetCollection(key string) (XDatasetCollectionDef, bool) {
// GetString will read the value of the key variable as a string cast type
func (d *XDataset) GetString(key string) (string, bool) {
if val, ok := d.Get(key); ok {
if val == nil {
return "", true
}
return fmt.Sprint(val), true
}
return "", false
Expand Down Expand Up @@ -511,6 +514,9 @@ func (d *XDatasetCollection) GetData(key string) (interface{}, bool) {
func (d *XDatasetCollection) GetDataString(key string) (string, bool) {
v, ok := d.GetData(key)
if ok {
if v == nil {
return "", true
}
return fmt.Sprint(v), true
}
return "", false
Expand Down
4 changes: 2 additions & 2 deletions xdataset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestXDataset_simple_print(t *testing.T) {
}

str = fmt.Sprintf("%#v", ds)
if str != "#xcore.XDataset{v1:123 v2:\"abc\" v3:true vpi:3.1415927 vt:time.Time{wall:0x0, ext:63713476800, loc:(*time.Location)(nil)}}" {
if str != "#xcore.XDataset{v1:123 v2:\"abc\" v3:true vpi:3.1415927 vt:time.Date(2020, time.January, 1, 12, 0, 0, 0, time.UTC)}" {
t.Error("Error creating and #printing simple XDataset " + str)
return
}
Expand Down Expand Up @@ -107,7 +107,7 @@ func TestCreateXDataset_complex_print(t *testing.T) {
}

str = fmt.Sprintf("%#v", data)
if str != "#xcore.XDataset{clientname:\"Fred\" clientpicture:\"face.jpg\" hobbies:XDatasetCollection[0:xcore.XDataset{name:Football sport:yes} 1:xcore.XDataset{name:Ping-pong sport:yes} 2:xcore.XDataset{name:Swimming sport:yes} 3:xcore.XDataset{name:Videogames sport:no} ] metadata:#xcore.XDataset{Salary:3568.65 hiredate:time.Time{wall:0x0, ext:0, loc:(*time.Location)(nil)} preferred-color:\"blue\"} preferredhobby:#xcore.XDataset{name:\"Baseball\" sport:\"yes\"}}" {
if str != "#xcore.XDataset{clientname:\"Fred\" clientpicture:\"face.jpg\" hobbies:XDatasetCollection[0:xcore.XDataset{name:Football sport:yes} 1:xcore.XDataset{name:Ping-pong sport:yes} 2:xcore.XDataset{name:Swimming sport:yes} 3:xcore.XDataset{name:Videogames sport:no} ] metadata:#xcore.XDataset{Salary:3568.65 hiredate:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC) preferred-color:\"blue\"} preferredhobby:#xcore.XDataset{name:\"Baseball\" sport:\"yes\"}}" {
t.Error("Error creating and #printing complex XDataset " + str)
return
}
Expand Down
3 changes: 3 additions & 0 deletions xtemplate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ func TestXTemplateSimple(t *testing.T) {
&XDataset{"name": "other 2", "sport": "no"},
&XDataset{"name": "other 3", "sport": "yes"},
&XDataset{"name": "other 4", "sport": "no"},
&XDataset{"name": "other 5", "sport": nil},
},
"preferredhobby": &XDataset{
"name": "Baseball",
Expand All @@ -181,10 +182,12 @@ func TestXTemplateSimple(t *testing.T) {
"#": lang,
}

// fmt.Println(data)
str := tmpl.Execute(&data)
if str == "" {
t.Errorf("Error build complex template")
}
// fmt.Println(str)
}

/*
Expand Down

0 comments on commit 715208f

Please sign in to comment.