etag

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package etag creates HTTP entity tags, a port of the npm "etag" package.

A strong tag is formatted as "<hex-len>-<base64-sha1>" where the base64 of the SHA-1 digest is truncated to 27 characters. A stat-based tag is formatted as "<hex-size>-<hex-mtime-ms>". Weak tags are prefixed with "W/".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(data []byte, weak bool) string

Generate computes an entity tag for the given content. When weak is true the tag is prefixed with "W/".

func GenerateStat

func GenerateStat(size int64, modtime time.Time, weak bool) string

GenerateStat computes a stat-based entity tag from a resource's size and modification time. The modification time is expressed in milliseconds since the Unix epoch. When weak is true the tag is prefixed with "W/".

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL