gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/internal/goroot/gccgo.go (about)

     1  // Copyright 2018 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build gccgo
     6  // +build gccgo
     7  
     8  package goroot
     9  
    10  import (
    11  	"os"
    12  	"path/filepath"
    13  )
    14  
    15  // IsStandardPackage reports whether path is a standard package,
    16  // given goroot and compiler.
    17  func IsStandardPackage(goroot, compiler, path string) bool {
    18  	switch compiler {
    19  	case "gc":
    20  		dir := filepath.Join(goroot, "src", path)
    21  		_, err := os.Stat(dir)
    22  		return err == nil
    23  	case "gccgo":
    24  		return stdpkg[path]
    25  	default:
    26  		panic("unknown compiler " + compiler)
    27  	}
    28  }