type ClientOps … var ErrWriteConflict … var ErrSecurity … type Client … // NewClient returns a new [Client] using the given [ClientOps]. func NewClient(ops ClientOps) *Client { … } // init initializes the client (if not already initialized) // and returns any initialization error. func (c *Client) init() error { … } // initWork does the actual initialization work. func (c *Client) initWork() { … } // SetTileHeight sets the tile height for the Client. // Any call to SetTileHeight must happen before the first call to [Client.Lookup]. // If SetTileHeight is not called, the Client defaults to tile height 8. // SetTileHeight can be called at most once, // and if so it must be called before the first call to Lookup. func (c *Client) SetTileHeight(height int) { … } // SetGONOSUMDB sets the list of comma-separated GONOSUMDB patterns for the Client. // For any module path matching one of the patterns, // [Client.Lookup] will return ErrGONOSUMDB. // SetGONOSUMDB can be called at most once, // and if so it must be called before the first call to Lookup. func (c *Client) SetGONOSUMDB(list string) { … } var ErrGONOSUMDB … func (c *Client) skip(target string) bool { … } // Lookup returns the go.sum lines for the given module path and version. // The version may end in a /go.mod suffix, in which case Lookup returns // the go.sum lines for the module's go.mod-only hash. func (c *Client) Lookup(path, vers string) (lines []string, err error) { … } // mergeLatest merges the tree head in msg // with the Client's current latest tree head, // ensuring the result is a consistent timeline. // If the result is inconsistent, mergeLatest calls c.ops.SecurityError // with a detailed security error message and then // (only if c.ops.SecurityError does not exit the program) returns ErrSecurity. // If the Client's current latest tree head moves forward, // mergeLatest updates the underlying configuration file as well, // taking care to merge any independent updates to that configuration. func (c *Client) mergeLatest(msg []byte) error { … } const msgPast … const msgNow … const msgFuture … // mergeLatestMem is like mergeLatest but is only concerned with // updating the in-memory copy of the latest tree head (c.latest) // not the configuration file. // The when result explains when msg happened relative to our // previous idea of c.latest: // msgPast means msg was from before c.latest, // msgNow means msg was exactly c.latest, and // msgFuture means msg was from after c.latest, which has now been updated. func (c *Client) mergeLatestMem(msg []byte) (when int, err error) { … } // checkTrees checks that older (from olderNote) is contained in newer (from newerNote). // If an error occurs, such as malformed data or a network problem, checkTrees returns that error. // If on the other hand checkTrees finds evidence of misbehavior, it prepares a detailed // message and calls log.Fatal. func (c *Client) checkTrees(older tlog.Tree, olderNote []byte, newer tlog.Tree, newerNote []byte) error { … } // checkRecord checks that record #id's hash matches data. func (c *Client) checkRecord(id int64, data []byte) error { … } type tileReader … func (r *tileReader) Height() int { … } // ReadTiles reads and returns the requested tiles, // either from the on-disk cache or the server. func (r *tileReader) ReadTiles(tiles []tlog.Tile) ([][]byte, error) { … } // tileCacheKey returns the cache key for the tile. func (c *Client) tileCacheKey(tile tlog.Tile) string { … } // tileRemotePath returns the remote path for the tile. func (c *Client) tileRemotePath(tile tlog.Tile) string { … } // readTile reads a single tile, either from the on-disk cache or the server. func (c *Client) readTile(tile tlog.Tile) ([]byte, error) { … } // markTileSaved records that tile is already present in the on-disk cache, // so that a future SaveTiles for that tile can be ignored. func (c *Client) markTileSaved(tile tlog.Tile) { … } // SaveTiles saves the now validated tiles. func (r *tileReader) SaveTiles(tiles []tlog.Tile, data [][]byte) { … }