doc.go 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. // SPDX-License-Identifier: Apache-2.0
  2. // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
  3. //go:build !cgo && (darwin || freebsd || linux)
  4. // Package fakecgo implements the Cgo runtime (runtime/cgo) entirely in Go.
  5. // This allows code that calls into C to function properly when CGO_ENABLED=0.
  6. //
  7. // # Goals
  8. //
  9. // fakecgo attempts to replicate the same naming structure as in the runtime.
  10. // For example, functions that have the prefix "gcc_*" are named "go_*".
  11. // This makes it easier to port other GOOSs and GOARCHs as well as to keep
  12. // it in sync with runtime/cgo.
  13. //
  14. // # Support
  15. //
  16. // Currently, fakecgo only supports macOS on amd64 & arm64. It also cannot
  17. // be used with -buildmode=c-archive because that requires special initialization
  18. // that fakecgo does not implement at the moment.
  19. //
  20. // # Usage
  21. //
  22. // Using fakecgo is easy just import _ "github.com/ebitengine/purego" and then
  23. // set the environment variable CGO_ENABLED=0.
  24. // The recommended usage for fakecgo is to prefer using runtime/cgo if possible
  25. // but if cross-compiling or fast build times are important fakecgo is available.
  26. // Purego will pick which ever Cgo runtime is available and prefer the one that
  27. // comes with Go (runtime/cgo).
  28. package fakecgo
  29. //go:generate go run gen.go