pointers and hashing
This commit is contained in:
parent
1425521d26
commit
0c2a0e72b3
@ -3,7 +3,7 @@ package bard
|
||||
import "time"
|
||||
|
||||
type BardCache struct {
|
||||
Bards map[string]Bard
|
||||
Bards map[string]*Bard
|
||||
}
|
||||
|
||||
func GarbageCollectCache(cache *BardCache) {
|
||||
@ -18,7 +18,7 @@ var cache *BardCache
|
||||
|
||||
func init() {
|
||||
cache = &BardCache{
|
||||
Bards: make(map[string]Bard),
|
||||
Bards: make(map[string]*Bard),
|
||||
}
|
||||
go func() {
|
||||
for {
|
||||
|
14
internal/bard/utilities.go
Normal file
14
internal/bard/utilities.go
Normal file
@ -0,0 +1,14 @@
|
||||
package bard
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
)
|
||||
|
||||
func HashConversation(conversation []string) string {
|
||||
hash := md5.New()
|
||||
for _, message := range conversation {
|
||||
hash.Write([]byte(message))
|
||||
}
|
||||
return hex.EncodeToString(hash.Sum(nil))
|
||||
}
|
Reference in New Issue
Block a user