Package-Level Type Names (total 13, in which 7 are exported)
/* sort exporteds by: | */
ASTTransformer is a default transformer of the goldmark tree.
Transform transforms the given AST tree to remove an unnecessary child
node from the image node. This is so that the summary generated doesn't
the text content of an image block.
*T : github.com/yuin/goldmark/parser.ASTTransformer
bypassLicenseCheckboolcancelfunc()db*database.DBexpoller*poller.Poller
CleanModule deletes all versions of the given module path from the DB and marks them
as cleaned in module_version_states.
CleanModuleVersions deletes each module version from the DB and marks it as cleaned
in module_version_states.
Close closes a DB.
DeleteModule deletes a Version from the database.
DeleteOlderVersionFromSearchDocuments deletes from search_documents every package with
the given module path whose version is older than the given version.
It is used when fetching a module with an alternative path. See internal/worker/fetch.go:fetchAndUpdateState.
DeletePseudoversionsExcept deletes all pseudoversions for the module except
the provided resolvedVersion.
GetExcludedPrefixes reads all the excluded prefixes from the database.
GetImportedBy fetches and returns all of the packages that import the
package with path.
The returned error may be checked with derrors.IsInvalidArgument to
determine if it resulted from an invalid package path or version.
Instead of supporting pagination, this query runs with a limit.
GetImportedByCount returns the number of packages that import pkgPath.
GetLatestInfo returns the latest information about the unit in the module.
See internal.LatestInfo for documentation about the returned values.
If latestUnitMeta is non-nil, it is the result of GetUnitMeta(unitPath, internal.UnknownModulePath, internal.LatestVersion).
That can save a redundant call to GetUnitMeta here.
GetLatestMajorPathForV1Path reports the latest unit path in the series for
the given v1path. It also returns the major version for that path.
GetLatestModuleVersions returns the row of the latest_module_versions table for modulePath.
If the module path is not found, it returns nil, nil.
GetModuleInfo fetches a module version from the database with the primary key
(module_path, version).
GetModuleReadme returns the README corresponding to the modulePath and version.
GetModuleVersionState returns the current module version state for
modulePath and version.
GetModuleVersionsToClean returns module versions that can be removed from the database.
Only module versions that were updated more than daysOld days ago will be considered.
At most limit module versions will be returned.
GetNestedModules returns the latest major version of all nested modules
given a modulePath path prefix with or without major version.
GetNextModulesToFetch returns the next batch of modules that need to be
processed. We prioritize modules based on (1) whether it has status zero
(never processed), (2) whether it is the latest version, (3) if it is an
alternative module, and (4) the number of packages it has. We want to leave
time-consuming modules until the end and process them at a slower rate to
reduce database load and timeouts. We also want to leave alternative modules
towards the end, since these will incur unnecessary deletes otherwise.
GetPackageVersionState returns the current package version state for
pkgPath, modulePath and version.
GetPackageVersionStatesForModule returns the current package version states
for modulePath and version.
GetPackagesForSearchDocumentUpsert fetches search information for packages in search_documents
whose update time is before the given time.
GetRecentFailedVersions returns versions that have most recently failed.
GetRecentVersions returns recent versions that have been processed.
GetStdlibPathsWithSuffix returns information about all paths in the latest version of the standard
library whose last component is suffix. A path that exactly match suffix is not included;
the path must end with "/" + suffix.
We are only interested in actual standard library packages: not commands, which we happen to include
in the stdlib module, and not directories (paths that do not contain a package).
GetSymbolHistory returns a SymbolHistory, which is a representation of the
first version when a symbol is added to an API.
GetUnit returns a unit from the database, along with all of the data
associated with that unit.
If bc is not nil, get only the Documentation that matches it (or nil if none do).
GetUnitMeta returns information about the "best" entity (module, path or directory) with
the given path. The module and version arguments provide additional constraints.
If the module is unknown, pass internal.UnknownModulePath; if the version is unknown, pass
internal.LatestVersion.
The rules for picking the best are:
1. If the version is known but the module path is not, choose the longest module path
at that version that contains fullPath.
2. Otherwise, find the latest "good" version (in the modules table) that contains fullPath.
a. First, follow the algorithm of the go command: prefer longer module paths, and
find the latest unretracted version, using semver but preferring release to pre-release.
b. If no modules have latest-version information, find the latest by sorting the versions
we do have: again first by module path length, then by version.
GetVersionMap fetches a version_map entry corresponding to the given
modulePath and requestedVersion.
GetVersionMaps returns all of the version maps for the provided
path and requested version if they are present.
GetVersionStats queries the module_version_states table for aggregate
information about the current state of module versions, grouping them by
their current status code.
GetVersionsForPath returns a list of tagged versions sorted in
descending semver order if any exist. If none, it returns the 10 most
recent from a list of pseudo-versions sorted in descending semver order.
HasGoMod reports whether a given module version has a go.mod file.
It returns a NotFound error if it can't find any information.
InsertExcludedPrefix inserts prefix into the excluded_prefixes table.
For real-time administration (e.g. DOS prevention), use the dbadmin tool.
to exclude or unexclude a prefix. If the exclusion is permanent (e.g. a user
request), also add the prefix and reason to the excluded.txt file.
InsertIndexVersions inserts new versions into the module_version_states
table with a status of zero.
InsertModule inserts a version into the database using db.saveVersion, along
with a search document corresponding to each of its packages.
It returns whether the version inserted was the latest for the given module path.
IsExcluded reports whether the path matches the excluded list.
A path matches an entry on the excluded list if it equals the entry, or
is a component-wise suffix of the entry.
So path "bad/ness" matches entries "bad" and "bad/", but path "badness"
matches neither of those.
LatestIndexTimestamp returns the last timestamp successfully inserted into
the module_version_states table.
ReInsertLatestVersion checks that the latest good version matches the version
in search_documents. If it doesn't, it inserts the latest good version into
search_documents and imports_unique.
Search executes two search requests concurrently:
- a sequential scan of packages in descending order of popularity.
- all packages ("deep" search) using an inverted index to filter to search
terms.
The sequential scan takes significantly less time when searching for very
common terms (e.g. "errors", "cloud", or "kubernetes"), due to its ability
to exit early once the requested page of search results is provably
complete.
Because 0 <= ts_rank() <= 1, we know that the highest score of any unscanned
package is ln(e+N), where N is imported_by_count of the package we are
currently considering. Therefore if the lowest scoring result of popular
search is greater than ln(e+N), we know that we haven't missed any results
and can return the search result immediately, cancelling other searches.
On the other hand, if the popular search is slow, it is likely that the
search term is infrequent, and deep search will be fast due to our inverted
gin index on search tokens.
The gap in this optimization is search terms that are very frequent, but
rarely relevant: "int" or "package", for example. In these cases we'll pay
the penalty of a deep search that scans nearly every package.
StalenessTimestamp returns the index timestamp of the oldest
module that is newer than the index timestamp of the youngest module we have
processed. That is, let T be the maximum index timestamp of all processed
modules. Then this function return the minimum index timestamp of unprocessed
modules that is no less than T, or an error that wraps derrors.NotFound if
there is none.
The name of the function is imprecise: there may be an older unprocessed
module, if one newer than it has been processed.
We use this function to compute a metric that is a lower bound on the time
it takes to process a module since it appeared in the index.
Underlying returns the *database.DB inside db.
UpdateLatestModuleVersions upserts its argument into the latest_module_versions table
if the row doesn't exist, or the new version is later.
It returns the version that is in the DB when it completes.
UpdateLatestModuleVersionsStatus updates or inserts a failure status into the
latest_module_versions table.
It only updates the table if it doesn't have valid information for the module path.
UpdateModuleVersionStatesForReprocessing marks modules to be reprocessed
that were processed prior to the provided appVersion.
UpdateModuleVersionStatesForReprocessingLatestOnly marks modules to be
reprocessed that were processed prior to the provided appVersion.
UpdateModuleVersionStatesForReprocessingReleaseVersionsOnly marks modules to be
reprocessed that were processed prior to the provided appVersion.
(*T) UpdateModuleVersionStatesWithStatus(ctx context.Context, status int, appVersion string) (err error)
UpdateModuleVersionStatus updates the status and error fields of a module version.
UpdateSearchDocumentsImportedByCount updates imported_by_count and
imported_by_count_updated_at.
It does so by completely recalculating the imported-by counts
from the imports_unique table.
UpdateSearchDocumentsImportedByCount returns the number of rows updated.
UpsertModuleVersionState inserts or updates the module_version_state table with
the results of a fetch operation for a given module version.
UpsertSearchDocumentWithImportedByCount is the same as UpsertSearchDocument,
except it also updates the imported by count. This is only used for testing.
UpsertVersionMap inserts a version_map entry into the database.
addPackageDataToSearchResults adds package information to SearchResults that is not stored
in the search_documents table.
compareLicenses compares m.Licenses with the existing licenses for
m.ModulePath and m.Version in the database. It returns an error if there
are licenses in the licenses table that are not present in m.Licenses.
comparePaths compares m.Directories with the existing directories for
m.ModulePath and m.Version in the database. It returns an error if there
are paths in the paths table that are not present in m.Directories.
(*T) computeImportedByCounts(ctx context.Context, searchDocsPackages map[string]bool) (counts map[string]int, err error)
deepSearch searches all packages for the query. It is slower, but results
are always valid.
getImports returns the imports corresponding to unitID.
getLatestMajorVersion returns the latest module path and the full package path
of the latest version found, given the fullPath and the modulePath.
For example, in the module path "github.com/casbin/casbin", there
is another module path with a greater major version "github.com/casbin/casbin/v3".
This function will return "github.com/casbin/casbin/v3" or the input module path
if no later module path was found. It also returns the full package path at the
latest module version if it exists. If not, it returns the module path.
getLatestMajorVersion only considers tagged (non-pseudo) versions. If there are none,
it returns empty strings.
getLatestUnitVersion gets the latest version of requestedModulePath that contains fullPath.
See GetUnitMeta for more details.
(*T) getLicenses(ctx context.Context, fullPath, modulePath string, unitID int) (_ []*licenses.License, err error)
getModuleLicenses returns all licenses associated with the given module path and
version. These are the top-level licenses in the module zip file.
It returns an InvalidArgument error if the module path or version is invalid.
(*T) getMultiLatestModuleVersions(ctx context.Context, modulePaths []string) (lmvs []*internal.LatestModuleVersions, err error)
getPackagesInUnit returns all of the packages in a unit from a
module_id, including the package that lives at fullPath, if present.
(*T) getPathsInModule(ctx context.Context, modulePath, resolvedVersion string) (_ []*dbPath, err error)
getSearchPackages returns the set of package paths that are in the search_documents table.
(*T) getUnitID(ctx context.Context, fullPath, modulePath, resolvedVersion string) (_ int, err error)(*T) getUnitMetaWithKnownLatestVersion(ctx context.Context, fullPath, modulePath, version string, lmv *internal.LatestModuleVersions) (_ *internal.UnitMeta, err error)(*T) getUnitWithAllFields(ctx context.Context, um *internal.UnitMeta, bc internal.BuildContext) (_ *internal.Unit, err error)
hedgedSearch executes multiple search methods and returns the first
available result.
The optional guardTestResult func may be used to allow tests to control the
order in which search results are returned.
insertUnits inserts the units for a module into the units table.
It can be assume that at least one unit is a package, and there are one or
more units in the module.
(*T) popularSearch(ctx context.Context, searchQuery string, limit, offset, maxResultCount int) searchResponse
queryModuleVersionStates executes a query for ModuleModuleVersionState rows. It expects the
given queryFormat be a format specifier with exactly one argument: a %s verb
for the query columns.
saveModule inserts a Module into the database along with its packages,
imports, and licenses. If any of these rows already exist, the module and
corresponding will be deleted and reinserted.
If the module is malformed then insertion will fail.
saveModule reports whether the version inserted is the latest known version
for the module path (that is, the latest minor version of the module)
A derrors.InvalidArgument error will be returned if the given module and
licenses are invalid.
symbolSearch searches all symbols in the symbol_search_documents table for
the query.
TODO(https://golang.org/issue/44142): factor out common code between
symbolSearch and deepSearch.
unitExistsAtLatest reports whether unitPath exists at the latest version of modulePath.
*T : golang.org/x/pkgsite/internal.DataSource
*T : io.Closer
func New(db *database.DB) *DB
func NewBypassingLicenseCheck(db *database.DB) *DB
func SetupTestDB(dbName string) (_ *DB, err error)
func golang.org/x/pkgsite/cmd/internal/cmdconfig.OpenDB(ctx context.Context, cfg *config.Config, bypassLicenseCheck bool) (_ *DB, err error)
func newdb(db *database.DB, bypass bool) *DB
func GetFromSearchDocuments(ctx context.Context, t *testing.T, db *DB, packagePath string) (modulePath, version string, found bool)
func InsertSampleDirectoryTree(ctx context.Context, t *testing.T, testDB *DB)
func MustInsertModule(ctx context.Context, t *testing.T, db *DB, m *internal.Module)
func MustInsertModuleGoMod(ctx context.Context, t *testing.T, db *DB, m *internal.Module, goMod string)
func MustInsertModuleNotLatest(ctx context.Context, t *testing.T, db *DB, m *internal.Module)
func ResetTestDB(db *DB, t *testing.T)
func RunDBTests(dbName string, m *testing.M, testDB **DB)
func golang.org/x/pkgsite/internal/frontend.FetchAndUpdateState(ctx context.Context, modulePath, requestedVersion string, proxyClient *proxy.Client, sourceClient *source.Client, db *DB) (_ int, err error)
func addLatest(ctx context.Context, t *testing.T, db *DB, modulePath, version, modFile string) *internal.LatestModuleVersions
func getPathVersions(ctx context.Context, db *DB, path string, versionTypes ...version.Type) (_ []*internal.ModuleInfo, err error)
func mustInsertModule(ctx context.Context, t *testing.T, db *DB, m *internal.Module, goMod string, latest bool)
func populateLatestInfo(ctx context.Context, db *DB, mi *internal.ModuleInfo) (err error)
func populateLatestInfos(ctx context.Context, db *DB, mis []*internal.ModuleInfo) (err error)
func golang.org/x/pkgsite/internal/frontend.checkForPath(ctx context.Context, db *DB, fullPath, modulePath, requestedVersion string, taskIDChangeInterval time.Duration) (fr *frontend.fetchResult)
func golang.org/x/pkgsite/internal/frontend.fetchSearchPage(ctx context.Context, db *DB, query string, pageParams frontend.paginationParams) (*frontend.SearchPage, error)
func golang.org/x/pkgsite/internal/frontend.pollForPath(ctx context.Context, db *DB, pollEvery time.Duration, fullPath, modulePath, requestedVersion string, taskIDChangeInterval time.Duration) *frontend.fetchResult
func golang.org/x/pkgsite/internal/frontend.previousFetchStatusAndResponse(ctx context.Context, db *DB, fullPath, modulePath, requestedVersion string) (_ *frontend.fetchResult, err error)
func golang.org/x/pkgsite/internal/frontend.stdlibPathForShortcut(ctx context.Context, db *DB, shortcut string) (path string, err error)
func golang.org/x/pkgsite/internal/frontend.(*Server).checkPossibleModulePaths(ctx context.Context, db *DB, fullPath, requestedVersion string, modulePaths []string, shouldQueue bool) []*frontend.fetchResult
func golang.org/x/pkgsite/internal/worker.deleteModule(ctx context.Context, db *DB, ft *worker.fetchTask) (err error)
func golang.org/x/pkgsite/internal/worker.updateVersionMap(ctx context.Context, db *DB, ft *worker.fetchTask) (err error)
func golang.org/x/pkgsite/cmd/worker.populateExcluded(ctx context.Context, db *DB)
jsonbScanner scans a jsonb value into a Go value.
// a pointer to a Go struct or other JSON-serializable value
( T) Scan(value interface{}) (err error)
T : database/sql.Scanner
searchEvent is used to log structured information about search events for
later analysis. A 'search event' occurs when a searcher or count estimate
returns.
Err is the error returned by the operation, if any.
Latency is the duration that that the operation took.
Type is either the searcher name or 'estimate' (the count estimate).
searchResponse is used for internal bookkeeping when fanning-out search
request to multiple different search queries.
err indicates a technical failure of the search query, or that results are
not provably complete.
results are partially filled out from only the search_documents table.
source is a unique identifier for the search query type (e.g. 'deep',
'popular'), to be used in logging and reporting.
func (*DB).deepSearch(ctx context.Context, q string, limit, offset, maxResultCount int) searchResponse
func (*DB).hedgedSearch(ctx context.Context, q string, limit, offset, maxResultCount int, searchers map[string]searcher, guardTestResult func(string) func()) (_ *searchResponse, err error)
func (*DB).popularSearch(ctx context.Context, searchQuery string, limit, offset, maxResultCount int) searchResponse
func (*DB).symbolSearch(ctx context.Context, q string, limit, offset, maxResultCount int) searchResponse
Package-Level Functions (total 93, in which 19 are exported)
GeneratePathTokens returns the subPaths and path token parts that will be
indexed for search, which includes (1) the packagePath (2) all sub-paths of
the packagePath (3) all parts for a path element that is delimited by a dash
and (4) all parts of a path element that is delimited by a dot, except for
the last element.
GetFromSearchDocuments retrieves the module path and version for the given
package path from the search_documents table. If the path is not in the table,
the third return value is false.
GetSymbolHistoryForBuildContext returns a map of the first version when a symbol name is
added to the API for the specified build context, to the symbol name, to the
UnitSymbol struct. The UnitSymbol.Children field will always be empty, as
children names are also tracked.
GetSymbolHistoryFromTable returns a SymbolHistory, which is a representation of the
first version when a symbol is added to an API. It reads data from the
symbol_history table.
GetSymbolHistoryWithPackageSymbols fetches symbol history data by using data
from package_symbols and documentation_symbols, and computed using
symbol.IntroducedHistory.
GetSymbolHistoryWithPackageSymbols is exported for use in tests.
InsertSampleDirectory tree inserts a set of packages for testing
GetUnit and frontend.FetchDirectoryDetails.
MustInsertModule inserts m into db, calling t.Fatal on error.
It also updates the latest-version information for m.
NewBypassingLicenseCheck returns a new postgres DB that bypasses license
checks. That means all data will be inserted and returned for
non-redistributable modules, packages and directories.
NewHTMLRenderer creates a new HTMLRenderer for a readme.
ResetTestDB truncates all data from the given test DB. It should be called
after every test that mutates the database.
RunDBTests is a wrapper that runs the given testing suite in a test database
named dbName. The given *DB reference will be set to the instantiated test
database.
RunDBTestsInParallel sets up numDBs databases, then runs the tests. Before it runs them,
it sets acquirep to a function that tests should use to acquire a database. The second
return value of the function should be called in a defer statement to release the database.
For example:
func Test(t *testing.T) {
db, release := acquire(t)
defer release()
SearchDocumentSections computes the B and C sections of a Postgres search
document from a package synopsis and a README.
By "B section" and "C section" we mean the portion of the tsvector with weight
"B" and "C", respectively.
The B section consists of the synopsis.
The C section consists of the first sentence of the README.
The D section consists of the remainder of the README.
All sections are split into words and processed for replacements.
Each section is limited to maxSectionWords words, and in addition the
D section is limited to an initial fraction of the README, determined
by maxReadmeFraction.
SetupTestDB creates a test database named dbName if it does not already
exist, and migrates it to the latest schema from the migrations directory.
UpsertSearchDocument inserts a row in search_documents for the given package.
The given module should have already been validated via a call to
validateModule.
compareLicenses reports whether i < j according to our license sorting
semantics.
getDocIDsForPath returns a map of the unit path to documentation.id to
documentation, for all of the docs in pathToDocs. This will be used to
insert data into the documentation_symbols.documentation_id column.
getLatestGoodVersion returns the latest version of a module in the modules
table, respecting the retractions and other information in the given
LatestModuleVersions. If lmv is nil, it finds the latest version, favoring
release over pre-release, including incompatible versions, and ignoring
retractions.
getPackageSymbols returns all of the symbols for a given package path and module path.
getPathVersions returns a list of versions sorted in descending semver
order. The version types included in the list are specified by a list of
VersionTypes.
getUnitSymbols returns all of the symbols for the given unitID.
groupSearchResults groups and re-orders the list of SearchResults by module
and series path and returns a new list of SearchResults.
The second and later packages from a module are grouped under the first package,
and removed from the top-level list.
Higher major versions of a module are put before lower ones.
Packages from lower major versions of the module are grouped under the first
package of the highest major version. But they are not removed from the
top-level list.
hyphenSplit reports whether s should be split on hyphens.
insertPaths inserts all paths in m that aren't already there, and returns a map from each path to its
ID in the paths table.
Should be run inside a transaction.
isAlternativeModulePath reports whether the module path is "alternative,"
that is, it disagrees with the module path in the go.mod file. This can
happen when someone forks a repo and does not change the go.mod file, or when
the path used to get a module is a case variant of the correct one (e.g.
github.com/Sirupsen/logrus vs. github.com/sirupsen/logrus).
isInternalPackage reports whether the path represents an internal directory.
isMarkdown reports whether filename says that the file contains markdown.
lock obtains an exclusive, transaction-scoped advisory lock on modulePath.
makeValidUnicode removes null runes from a string that will be saved in a
column of type TEXT, because pq doesn't like them. It also replaces non-unicode
characters with the Unicode replacement character, which is the behavior of
for ... range on strings.
migrationsSource returns a uri pointing to the migrations directory. It
returns an error if unable to determine this path.
mustHaveColumns panics if the columns of rows does not match wantColumns.
processMarkdown returns the text of a markdown document.
It omits all formatting and images.
processWord performs processing on s, returning zero or more words.
Its main purpose is to apply summaryReplacements to replace
certain words with synonyms or additional search terms.
processWords splits s into words at whitespace, then processes each word.
rawIsMoreRecent reports whether raw version v1 is more recent than v2.
v1 is more recent if it is later according to the go command (higher semver,
preferring release to prerelease). However, the raw latest version can go
backwards if it was an incompatible version, but then a compatible version
with a go.mod file is published. For example, the module starts with a
v2.0.0+incompatible, but then the author adds a v1.0.0 with a go.mod file,
making v1.0.0 the new latest.
recreateDB drops and recreates the database named dbName.
removePkgPrefix removes the /pkg path prefix from links in docHTML.
See documentation for packageLinkRegexp for explanation and
TestRemovePkgPrefix for examples. It preserves the safety of its argument.
That is, if docHTML is safe from XSS attacks, so is
removePkgPrefix(docHTML).
Although we don't add "/pkg" to links after https://golang.org/cl/259101,
do not remove this function until all databases have been reprocessed.
scanModuleInfo constructs an *internal.ModuleInfo from the given scanner.
scanModuleVersionState constructs an *internal.ModuleModuleVersionState from the given
scanner. It expects columns to be in the order of moduleVersionStateColumns.
sentenceEndIndex returns the index in s of the end of the first sentence, or
-1 if no end can be found. A sentence ends at a '.', '!' or '?' that is
followed by a space (or ends the string), and is not preceded by an
uppercase letter.
shouldUpdateSymbolHistory reports whether the row for the given symbolName
should be updated. oldHist contains all of the current symbols in the
database for the same package and GOOS/GOARCH.
shouldUpdateSymbolHistory reports true if the symbolName does not currently
exist, or if the newVersion is older than or equal to the current database version.
split splits a slice of strings into two parts. The first has length <= n,
and the second is the rest of the slice. If n is negative, the first part is nil and
the second part is the entire slice.
tryToMigrate attempts to migrate the database named dbName to the latest
migration. If this operation fails in the migration step, it returns
isMigrationError=true to signal that the database should be recreated.
updateImportedByCounts updates the imported_by_count column in search_documents
for every package in computed_imported_by_counts.
A row is updated even if the value doesn't change, so that the imported_by_count_updated_at
column is set.
Note that if a package is never imported, its imported_by_count column will
be the default (0) and its imported_by_count_updated_at column will never be set.
updateLatestGoodVersion updates latest_module_versions.good_version for modulePath to version.
updateModulesStatus updates the status of the module with the given modulePath
and version, if it exists, in the modules table.
upsertPath adds path into the paths table if it does not exist, and returns
its ID either way.
It assumes it is running inside a transaction.
upsertPaths adds all the paths to the paths table if they aren't already
there, and returns their ID either way.
It assumes it is running inside a transaction.
upsertSearchDocuments adds search information for mod to the search_documents table.
It assumes that all non-redistributable data has been removed from mod.
validateModule checks that fields needed to insert a module into the database
are present. Otherwise, it returns an error listing the reasons the module
cannot be inserted. Since the problems it looks for are most likely on our
end, the underlying error it returns is always DBModuleInsertInvalid, meaning
that this module should be reprocessed.
keySearchSource is a census tag for search query types.
largeModulesLimit represents the number of large modules that we are
willing to enqueue at a given time.
var for testing.
packageLinkRegexp matches cross-package identifier links that have been
generated by the dochtml package. At the time this hack was added, these
links are all constructed to have either the form
<a href="/pkg/[path]">[name]</a>
or the form
<a href="/pkg/[path]#identifier">[name]</a>
The packageLinkRegexp mutates these links as follows:
- remove the now unnecessary '/pkg' path prefix
The pkgSearchers used by Search.
scoreExpr is the expression that computes the search score.
It is the product of:
- The Postgres ts_rank score, based the relevance of the document to the query.
- The log of the module's popularity, estimated by the number of importing packages.
The log factor contains exp(1) so that it is always >= 1. Taking the log
of imported_by_count instead of using it directly makes the effect less
dramatic: being 2x as popular only has an additive effect.
- A penalty factor for non-redistributable modules, since a lot of
details cannot be displayed.
The first argument to ts_rank is an array of weights for the four tsvector sections,
in the order D, C, B, A.
The weights below match the defaults except for B.
searchLatency holds observed latency in individual search queries.
For testing.
summaryReplacements is used to replace words with other words.
It is used by processWord, below.
Example key-value pairs:
"deleteMe": nil // removes "deleteMe"
"rand": []string{"random"} // replace "rand" with "random"
"utf-8": []string{"utf-8", "utf8"} // add "utf8" whenever "utf-8" is seen
largeModulePackageThresold represents the package threshold at which it
becomes difficult to process packages. Modules with more than this number
of packages are generally different versions or forks of kubernetes,
aws-sdk-go, azure-sdk-go, and bilibili.
This query prioritizes latest versions, but other than that, it tries
to avoid grouping modules in any way except by latest and status code:
processing is much smoother when they are enqueued in random order.
To make the result deterministic for testing, we hash the module path and version
rather than actually choosing a random number. md5 is built in to postgres and
is an adequate hash for this purpose.
Module does not have a go.mod file.
Start this off gently (close to 1), but consider lowering
it as time goes by and more of the ecosystem converts to modules.
Module license is non-redistributable.
The pages are generated with Goldsv0.3.2-preview. (GOOS=darwin GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.