// Generated by Lisette bindgen
// Source: go/build (Go stdlib)
// Go: 1.25.10
// Lisette: 0.2.1

import "go:go/token"
import "go:io"
import "go:io/fs"

/// ArchChar returns "?" and an error.
/// In earlier versions of Go, the returned string was used to derive
/// the compiler and linker tool names, the default object file suffix,
/// and the default linker output name. As of Go 1.5, those strings
/// no longer vary by architecture; they are compile, link, .o, and a.out, respectively.
pub fn ArchChar(goarch: string) -> Result<string, error>

/// Import is shorthand for Default.Import.
pub fn Import(path: string, srcDir: string, mode: ImportMode) -> Partial<Ref<Package>, error>

/// ImportDir is shorthand for Default.ImportDir.
pub fn ImportDir(dir: string, mode: ImportMode) -> Partial<Ref<Package>, error>

/// IsLocalImport reports whether the import path is
/// a local import path, like ".", "..", "./foo", or "../foo".
pub fn IsLocalImport(path: string) -> bool

/// A Context specifies the supporting context for a build.
pub struct Context {
  pub GOARCH: string,
  pub GOOS: string,
  pub GOROOT: string,
  pub GOPATH: string,
  pub Dir: string,
  pub CgoEnabled: bool,
  pub UseAllFiles: bool,
  pub Compiler: string,
  pub BuildTags: Slice<string>,
  pub ToolTags: Slice<string>,
  pub ReleaseTags: Slice<string>,
  pub InstallSuffix: string,
  pub JoinPath: Option<fn(VarArgs<string>) -> string>,
  pub SplitPathList: Option<fn(string) -> Slice<string>>,
  pub IsAbsPath: Option<fn(string) -> bool>,
  pub IsDir: Option<fn(string) -> bool>,
  pub HasSubdir: Option<fn(string, string) -> Option<string>>,
  pub ReadDir: Option<fn(string) -> Result<Slice<fs.FileInfo>, error>>,
  pub OpenFile: Option<fn(string) -> Result<io.ReadCloser, error>>,
}

/// A Directive is a Go directive comment (//go:zzz...) found in a source file.
pub struct Directive {
  pub Text: string,
  pub Pos: token.Position,
}

/// An ImportMode controls the behavior of the Import method.
#[go(bit_flag_set)]
pub struct ImportMode(uint)

/// MultiplePackageError describes a directory containing
/// multiple buildable Go source files for multiple packages.
pub struct MultiplePackageError {
  pub Dir: string,
  pub Packages: Slice<string>,
  pub Files: Slice<string>,
}

/// NoGoError is the error used by [Import] to describe a directory
/// containing no buildable Go source files. (It may still contain
/// test files, files hidden by build tags, and so on.)
pub struct NoGoError {
  pub Dir: string,
}

/// A Package describes the Go package found in a directory.
pub struct Package {
  pub Dir: string,
  pub Name: string,
  pub ImportComment: string,
  pub Doc: string,
  pub ImportPath: string,
  pub Root: string,
  pub SrcRoot: string,
  pub PkgRoot: string,
  pub PkgTargetRoot: string,
  pub BinDir: string,
  pub Goroot: bool,
  pub PkgObj: string,
  pub AllTags: Slice<string>,
  pub ConflictDir: string,
  pub BinaryOnly: bool,
  pub GoFiles: Slice<string>,
  pub CgoFiles: Slice<string>,
  pub IgnoredGoFiles: Slice<string>,
  pub InvalidGoFiles: Slice<string>,
  pub IgnoredOtherFiles: Slice<string>,
  pub CFiles: Slice<string>,
  pub CXXFiles: Slice<string>,
  pub MFiles: Slice<string>,
  pub HFiles: Slice<string>,
  pub FFiles: Slice<string>,
  pub SFiles: Slice<string>,
  pub SwigFiles: Slice<string>,
  pub SwigCXXFiles: Slice<string>,
  pub SysoFiles: Slice<string>,
  pub CgoCFLAGS: Slice<string>,
  pub CgoCPPFLAGS: Slice<string>,
  pub CgoCXXFLAGS: Slice<string>,
  pub CgoFFLAGS: Slice<string>,
  pub CgoLDFLAGS: Slice<string>,
  pub CgoPkgConfig: Slice<string>,
  pub TestGoFiles: Slice<string>,
  pub XTestGoFiles: Slice<string>,
  pub Directives: Slice<Directive>,
  pub TestDirectives: Slice<Directive>,
  pub XTestDirectives: Slice<Directive>,
  pub Imports: Slice<string>,
  pub ImportPos: Map<string, Slice<token.Position>>,
  pub TestImports: Slice<string>,
  pub TestImportPos: Map<string, Slice<token.Position>>,
  pub XTestImports: Slice<string>,
  pub XTestImportPos: Map<string, Slice<token.Position>>,
  pub EmbedPatterns: Slice<string>,
  pub EmbedPatternPos: Map<string, Slice<token.Position>>,
  pub TestEmbedPatterns: Slice<string>,
  pub TestEmbedPatternPos: Map<string, Slice<token.Position>>,
  pub XTestEmbedPatterns: Slice<string>,
  pub XTestEmbedPatternPos: Map<string, Slice<token.Position>>,
}

pub const AllowBinary: ImportMode = 2

pub const FindOnly: ImportMode = 1

pub const IgnoreVendor: ImportMode = 8

pub const ImportComment: ImportMode = 4

pub var Default: Context

/// ToolDir is the directory containing build tools.
pub var ToolDir: string

impl Context {
  /// Import returns details about the Go package named by the import path,
  /// interpreting local import paths relative to the srcDir directory.
  /// If the path is a local import path naming a package that can be imported
  /// using a standard import path, the returned package will set p.ImportPath
  /// to that path.
  /// 
  /// In the directory containing the package, .go, .c, .h, and .s files are
  /// considered part of the package except for:
  /// 
  ///   - .go files in package documentation
  ///   - files starting with _ or . (likely editor temporary files)
  ///   - files with build constraints not satisfied by the context
  /// 
  /// If an error occurs, Import returns a non-nil error and a non-nil
  /// *[Package] containing partial information.
  fn Import(self: Ref<Context>, path: string, srcDir: string, mode: ImportMode) -> Partial<Ref<Package>, error>

  /// ImportDir is like [Import] but processes the Go package found in
  /// the named directory.
  fn ImportDir(self: Ref<Context>, dir: string, mode: ImportMode) -> Partial<Ref<Package>, error>

  /// MatchFile reports whether the file with the given name in the given directory
  /// matches the context and would be included in a [Package] created by [ImportDir]
  /// of that directory.
  /// 
  /// MatchFile considers the name of the file and may use ctxt.OpenFile to
  /// read some or all of the file's content.
  fn MatchFile(self: Ref<Context>, dir: string, name: string) -> Result<bool, error>

  /// SrcDirs returns a list of package source root directories.
  /// It draws from the current Go root and Go path but omits directories
  /// that do not exist.
  fn SrcDirs(self: Ref<Context>) -> Slice<string>
}

impl MultiplePackageError {
  fn Error(self: Ref<MultiplePackageError>) -> string
}

impl NoGoError {
  fn Error(self: Ref<NoGoError>) -> string
}

impl Package {
  /// IsCommand reports whether the package is considered a
  /// command to be installed (not just a library).
  /// Packages named "main" are treated as commands.
  fn IsCommand(self: Ref<Package>) -> bool
}
