_content/blog/unique: fix bug in interning example

Thanks to Scott Kirkwood for pointing it out.

Change-Id: Id5d46b5ca5619b40aa6585ff85cd8ee26f8e4fb6
Reviewed-on: https://go-review.googlesource.com/c/website/+/608895
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Michael Anthony Knyszek 2024-08-27 20:32:38 +00:00 коммит произвёл Gopher Robot
Родитель 2ce22e2926
Коммит f6ad650466
1 изменённых файлов: 4 добавлений и 4 удалений

Просмотреть файл

@ -31,14 +31,14 @@ var internPool map[string]string
// Intern returns a string that is equal to s but that may share storage with
// a string previously passed to Intern.
func Intern(s string) string {
s, ok := internPool[s]
pooled, ok := internPool[s]
if !ok {
// Clone the string in case it's part of some much bigger string.
// This should be rare, if interning is being used well.
s = strings.Clone(s)
internPool[s] = s
pooled = strings.Clone(s)
internPool[pooled] = pooled
}
return s
return pooled
}
```