Copyright 2021 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

package symbol

import (
	
	
	

	
	
)
CompareAPIVersions returns the differences between apiVersions and inVersionToNameToUnitSymbol.
func ( string,  pkgAPIVersions,  *internal.SymbolHistory) ([]string, error) {
	,  := IntroducedHistory()
	if  != nil {
		return nil, 
	}
Create a map of name to the first version when the symbol name was found in the package.
	 := map[string]string{}
	for ,  := range .Versions() {
		 := .SymbolsAtVersion()
		if stdlib.Contains() {
			,  = stdlib.TagForVersion()
			if  != nil {
				return nil, 
			}
		}
Track the first version when the symbol name is added. It is possible for the symbol name to appear in multiple versions if it is introduced at different build contexts. The godoc logic that generates apiVersions does not take build context info into account.
			if ,  := []; ! {
				[] = 
			}
		}
	}

	var  []string

	 := func( string) bool {
The Go api/goN.txt files contain a Foo.embedded row when a new field is added. pkgsite does not currently handle embedding, so skip this check. type UnspecifiedType struct, embedded BasicType in https://go.googlesource.com/go/+/0e85fd7561de869add933801c531bf25dee9561c/api/go1.4.txt#62 is an example. cmd/api code at https://go.googlesource.com/go/+/go1.16/src/cmd/api/goapi.go#924.
			return true
		}
		if ,  := pathToEmbeddedMethods[];  {
			if ,  := [];  {
				return true
			}
		}
		if ,  := pathToExceptions[];  {
			if ,  := [];  {
				return true
			}
		}
		return false
	}
	 := func(,  string) {
		if stdlib.Contains() && () {
			return
		}

		,  := []
		delete(, )
		if ! {
The api/goN.txt files contain embedded fields and methods, which pkg.go.dev does not surface.
				 = append(, fmt.Sprintf("not found: (want %q) %q \n", , ))
			}
		} else if  !=  {
			 = append(, fmt.Sprintf("mismatch: (want %q | got %q) %q\n", , , ))
		}
	}

	for ,  := range []map[string]string{
		.constSince,
		.varSince,
		.funcSince,
		.typeSince,
	} {
		for ,  := range  {
			(, )
		}
	}
	for ,  := range .methodSince {
		for ,  := range  {
			 = strings.TrimPrefix(, "*")
			(+"."+, )
		}
	}
	for ,  := range .fieldSince {
		for ,  := range  {
			(+"."+, )
		}
	}
Some symbols may be missing when parsing the api/goN.txt files due to build contexts. Ignore these errors to reduce noise.
		for ,  := range  {
			 = append(, fmt.Sprintf("extra symbol: %q %q\n", , ))
		}
	}
	sort.Strings()
	return , nil