tpl: Improve template funcs GoDoc

This commit is contained in:
Bjørn Erik Pedersen
2022-12-21 13:11:08 +01:00
parent aa2c724195
commit cd1ed563a8
17 changed files with 170 additions and 163 deletions

View File

@@ -36,9 +36,9 @@ func New() *Namespace {
// Namespace provides template functions for the "crypto" namespace.
type Namespace struct{}
// MD5 hashes the given input and returns its MD5 checksum.
func (ns *Namespace) MD5(in any) (string, error) {
conv, err := cast.ToStringE(in)
// MD5 hashes the v and returns its MD5 checksum.
func (ns *Namespace) MD5(v any) (string, error) {
conv, err := cast.ToStringE(v)
if err != nil {
return "", err
}
@@ -47,9 +47,9 @@ func (ns *Namespace) MD5(in any) (string, error) {
return hex.EncodeToString(hash[:]), nil
}
// SHA1 hashes the given input and returns its SHA1 checksum.
func (ns *Namespace) SHA1(in any) (string, error) {
conv, err := cast.ToStringE(in)
// SHA1 hashes v and returns its SHA1 checksum.
func (ns *Namespace) SHA1(v any) (string, error) {
conv, err := cast.ToStringE(v)
if err != nil {
return "", err
}
@@ -58,9 +58,9 @@ func (ns *Namespace) SHA1(in any) (string, error) {
return hex.EncodeToString(hash[:]), nil
}
// SHA256 hashes the given input and returns its SHA256 checksum.
func (ns *Namespace) SHA256(in any) (string, error) {
conv, err := cast.ToStringE(in)
// SHA256 hashes v and returns its SHA256 checksum.
func (ns *Namespace) SHA256(v any) (string, error) {
conv, err := cast.ToStringE(v)
if err != nil {
return "", err
}
@@ -69,9 +69,9 @@ func (ns *Namespace) SHA256(in any) (string, error) {
return hex.EncodeToString(hash[:]), nil
}
// FNV32a hashes using fnv32a algorithm
func (ns *Namespace) FNV32a(in any) (int, error) {
conv, err := cast.ToStringE(in)
// FNV32a hashes v using fnv32a algorithm.
func (ns *Namespace) FNV32a(v any) (int, error) {
conv, err := cast.ToStringE(v)
if err != nil {
return 0, err
}