Skip to content

Commit 15c8ddc

Browse files
committed
types.Int: Implement ID interface
1 parent 82c901e commit 15c8ddc

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/types/int.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import (
66
"database/sql/driver"
77
"encoding"
88
"encoding/json"
9+
"fmt"
910
"github.com/icinga/icingadb/internal"
11+
"github.com/icinga/icingadb/pkg/contracts"
1012
"strconv"
1113
)
1214

@@ -58,11 +60,16 @@ func (i *Int) UnmarshalJSON(data []byte) error {
5860
return nil
5961
}
6062

63+
func (i Int) String() string {
64+
return fmt.Sprintf("%d", i.Int64)
65+
}
66+
6167
// Assert interface compliance.
6268
var (
6369
_ json.Marshaler = Int{}
6470
_ json.Unmarshaler = (*Int)(nil)
6571
_ encoding.TextUnmarshaler = (*Int)(nil)
6672
_ driver.Valuer = Int{}
6773
_ sql.Scanner = (*Int)(nil)
74+
_ contracts.ID = (*Int)(nil)
6875
)

0 commit comments

Comments
 (0)