mirror of
https://github.com/lukaszraczylo/filepuff-mcp.git
synced 2026-10-12 04:54:27 +00:00
docs(cursor): justify the ignored json.Marshal error in Encode
Per the project's error-handling rule, an ignored error needs a comment. Marshalling the two-scalar payload struct cannot fail; document why the error is dropped. No behavior change.
This commit is contained in:
@@ -26,6 +26,8 @@ type payload struct {
|
|||||||
// Encode creates an opaque cursor string from an offset and query hash.
|
// Encode creates an opaque cursor string from an offset and query hash.
|
||||||
func Encode(offset int, queryHash string) string {
|
func Encode(offset int, queryHash string) string {
|
||||||
p := payload{Offset: offset, QueryHash: queryHash}
|
p := payload{Offset: offset, QueryHash: queryHash}
|
||||||
|
// Marshalling a struct of two scalar fields (int, string) cannot fail, so the
|
||||||
|
// error is intentionally ignored.
|
||||||
b, _ := json.Marshal(p)
|
b, _ := json.Marshal(p)
|
||||||
return base64.RawURLEncoding.EncodeToString(b)
|
return base64.RawURLEncoding.EncodeToString(b)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user