golang.org/x/build@v0.0.0-20240506185731-218518f32b70/internal/loghash/loghash.go (about) 1 // Copyright 2015 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Package loghash provides the shared information for computing 6 // a log hash (as in https://build.golang.org/log/HASH). 7 package loghash 8 9 import ( 10 "crypto/sha1" 11 "fmt" 12 "io" 13 ) 14 15 // New returns a new hash for the given log text. 16 func New(text string) (hash string) { 17 h := sha1.New() 18 io.WriteString(h, text) 19 return fmt.Sprintf("%x", h.Sum(nil)) 20 }