![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
github.com/cnf/structhash
structhash is a Go library for generating hash strings of arbitrary data structures.
json.Marshal
, but using different struct tag)json.Marshal
)Standard go get
:
$ go get github.com/cnf/structhash
For usage and examples see the Godoc.
package main
import (
"fmt"
"crypto/md5"
"crypto/sha1"
"github.com/cnf/structhash"
)
type S struct {
Str string
Num int
}
func main() {
s := S{"hello", 123}
hash, err := structhash.Hash(s, 1)
if err != nil {
panic(err)
}
fmt.Println(hash)
// Prints: v1_41011bfa1a996db6d0b1075981f5aa8f
fmt.Println(structhash.Version(hash))
// Prints: 1
fmt.Printf("%x\n", structhash.Md5(s, 1))
// Prints: 41011bfa1a996db6d0b1075981f5aa8f
fmt.Printf("%x\n", structhash.Sha1(s, 1))
// Prints: 5ff72df7212ce8c55838fb3ec6ad0c019881a772
fmt.Printf("%x\n", md5.Sum(structhash.Dump(s, 1)))
// Prints: 41011bfa1a996db6d0b1075981f5aa8f
fmt.Printf("%x\n", sha1.Sum(structhash.Dump(s, 1)))
// Prints: 5ff72df7212ce8c55838fb3ec6ad0c019881a772
}
structhash supports struct tags in the following forms:
hash:"-"
, orhash:"name:{string} version:{number} lastversion:{number} method:{string}"
All fields are optional and may be ommitted. Their semantics is:
-
- ignore fieldname:{string}
- rename field (may be useful when you want to rename field but keep hashes unchanged for backward compatibility)version:{number}
- ignore field if version passed to structhash is smaller than given numberlastversion:{number}
- ignore field if version passed to structhash is greater than given numbermethod:{string}
- use the return value of a field's method instead of the field itselfExample:
type MyStruct struct {
Ignored string `hash:"-"`
Renamed string `hash:"name:OldName version:1"`
Legacy string `hash:"version:1 lastversion:2"`
Serialized error `hash:"method:Error"`
}
When hash is calculated, nil pointers, nil slices, and nil maps are treated equally to zero values of corresponding type. E.g., nil pointer to string is equivalent to empty string, and nil slice is equivalent to empty slice.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.