go-packages's People
go-packages's Issues
[errors] Create a structured and programatic caring standard for surfacing a humanized error message
[feature request][pagination] add encode/decode methods for integer cursors
Description
Would like to have encode/decode methods for integer cursors. Use case is for tables with integer IDs like the redirect
table in the url-management
service.
uuid isNil is broken in uuid package. Need isNil() or uuid.Nil to check if an uuid is empty or nil
var exampleID uuid
exampleID.IsNil()
// panic: reflect: call of reflect.Value.IsNil on array Value
[context][tracing] Insert traceability data, and request ID data into context and make sure it gets passed across grpc meta data
[uuid] Parse and ParseUUIDs should return an error for invalid entries
Background
Parse
and ParseUUIDs
currently return an empty UUID when given an empty string. I think this a carryover from a SQL database-specific implementation. I feel it is unexpected behavior outside of that context.
Proposed Solution
Parse
and ParseUUIDs
should behave like the underlying google counterpart and error when an empty string is passed in. Additionally, we may want to rename these methods to ParseString
and ParseStrings
in the event we add other methods like ParseBytes
. This could help prevent breaking change by deprecating the old methods. Two new methods should be added (potentially) to contain the previous behavior. These could be called ParseStringOrEmpty
and ParseStringsOrEmpty
.
[logging] Implement request middle-ware so that traceability and request meta-data is correctly logged
[errors] Add a WithErrDetails method so that error details can easily be added to an error
Export an interface for the logger to make major version changes less breaking
Currently, after the v1- > v2 change it is not possible to upgrade the logger in some places because the type's between v1 and v2 are incompatible. An interface would solve this issue and allow forward compatibility.
[uuid] Create a better way to interface with gofrs uuid
Background
https://pkg.go.dev/github.com/gofrs/uuid?utm_source=godoc
gofrs is used by the the event store DB Go SDK. Currently, there isn't a clean way to convert between the two types, because we have wrapped the underlying [16]byte
byte array in a struct. Below is what I have currently been doing.
ID, err := gofrs.FromString(m.EventID().String())
Potential Solutions
- Cast the underlying byte array to the gofrs uuid then return that. Implementation would be something like follows
func (uuid UUID) GofrsUUID() gofrs.UUID
- Return the underlying byte array through a method so that gofrs can parse it. (this way is a little more verbose but it is cleaner
func (uuid UUID) Bytes() []byte
id, err := gofrs.FromBytes(uuid.New())
Other considerations
We will likely need a way to go gofrs uuid -> caring uuid
[logging] Add utility so that traceability and request ID data can easily be extracted from context before logging anywhere in the application
Need nullValue method to be added to uuid pkg
if an uuid is empty, need to insert a null value to mysql database instead of "00000000-0000-0000-0000-000000000000"
use case:
result, err = stmt.ExecContext(ctx, input.ID, input.Name, input.StatusID, nullValueUUID(input.CustomerID), nullValueUUID(input.OrgID))
if err != nil {
return errors.Wrap(err, errMsg())
}
// nullUUID checks if an uuid is empty and returns a sql null string.
func nullValueUUID(id uuid.UUID) sql.NullString {
if id == uuid.Nil {
return sql.NullString{String: id.String(), Valid: false}
} else {
return sql.NullString{String: id.String(), Valid: true}
}
}
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.