compat

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2025 License: CC0-1.0 Imports: 4 Imported by: 0

README

Go Repository Template

Keep a Changelog Go Reference go.mod LICENSE Go Report Card Codecov

Star this repository if you find it valuable and worth maintaining.

👁 Watch this repository to get notified about new releases, issues, etc.

Description

This is a GitHub repository template for a Go application. You can use it:

  • to create a new repository with automation and environment setup,
  • as reference when improving automation for an existing repository.

It includes:

Usage

  1. Sign up on Codecov and configure Codecov GitHub Application.
  2. Click the Use this template button (alt. clone or download this repository).
  3. Replace all occurrences of rasa/compat to your_org/repo_name in all files.
  4. Replace all occurrences of seed to repo_name in Dockerfile.
  5. Follow these instructions to add the CODECOV_TOKEN GitHub Actions and Dependabot secret.
  6. Update the following files:

Setup

Below you can find sample instructions on how to set up the development environment. Of course, you can use other tools like GoLand, Vim, Emacs. However, take notice that the Visual Studio Go extension is officially supported by the Go team.

  1. Install Go.
  2. Install Visual Studio Code.
  3. Install Go extension.
  4. Clone and open this repository.
  5. F1 -> Go: Install/Update Tools -> (select all) -> OK.

Build

Terminal
  • make - execute the build pipeline.
  • make help - print help for the Make targets.
Visual Studio Code

F1Tasks: Run Build Task (Ctrl+Shift+B or ⇧⌘B) to execute the build pipeline.

Release

The release workflow is triggered each time a tag with v prefix is pushed.

CAUTION: Make sure to understand the consequences before you bump the major version. More info: Go Wiki, Go Blog.

Maintenance

Notable files:

FAQ

Why Visual Studio Code editor configuration

Developers that use Visual Studio Code can take advantage of the editor configuration. While others do not have to care about it. Setting configs for each repo is unnecessary time consuming. VS Code is the most popular Go editor (survey) and it is officially supported by the Go team.

You can always remove the .vscode directory if it really does not help you.

Why GitHub Actions, not any other CI server

GitHub Actions is out-of-the-box if you are already using GitHub. Here you can learn how to use it for Go.

However, changing to any other CI server should be very simple, because this repository has build logic and tooling installation in Makefile.

How can I build on Windows

Install tdm-gcc and copy C:\TDM-GCC-64\bin\mingw32-make.exe to C:\TDM-GCC-64\bin\make.exe. Alternatively, you may install mingw-w64 and copy mingw32-make.exe accordingly.

Take a look here, if you have problems using Docker in Git Bash.

You can also use WSL (Windows Subsystem for Linux) or develop inside a Remote Container. However, take into consideration that then you are not going to use "bare-metal" Windows.

Consider using goyek for creating cross-platform build pipelines in Go.

How can I customize the release

Take a look at GoReleaser docs as well as its repo how it is dogfooding its functionality. You can use it to add deb/rpm/snap packages, Homebrew Tap, Scoop App Manifest etc.

If you are developing a library and you like handcrafted changelog and release notes, you are free to remove any usage of GoReleaser.

Contributing

Feel free to create an issue or propose a pull request.

Follow the Code of Conduct.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SameDevice

func SameDevice(fi1, fi2 FileInfo) bool

SameDevice reports whether fi1 and fi2 describe files on the same device. For example, on Unix this means that the device fields of the two underlying structures are identical; on other systems the decision may be based on the path names. SameDevice only applies to results returned by this package's Stat. It returns false in other cases.

func SameDevices

func SameDevices(name1, name2 string) bool

SameDevices reports whether name1 and name2 are files on the same device. The function follow symlinks.

func SameFile

func SameFile(fi1, fi2 FileInfo) bool

SameFile reports whether fi1 and fi2 describe the same file. For example, on Unix this means that the device and inode fields of the two underlying structures are identical; on other systems the decision may be based on the path names. SameDevice only applies to results returned by this package's Stat. It returns false in other cases.

func SameFiles

func SameFiles(name1, name2 string) bool

SameFiles reports whether name1 and name2 are the same file. The function follow symlinks.

func Supports

func Supports(probe SupportsType) bool

Supports returns whether probe is supported by the operating system.

Types

type FileInfo

type FileInfo interface {
	Name() string       // base name of the file
	Size() int64        // length in bytes for regular files; system-dependent for others
	Mode() os.FileMode  // file mode bits
	ModTime() time.Time // last modified time
	IsDir() bool        // abbreviation for Mode().IsDir()
	Sys() any           // underlying data source
	DeviceID() uint64   // device ID
	FileID() uint64     // file ID
	Links() uint64      // number of hard links, or 0 if unsupported
	ATime() time.Time   // last accessed time, or 0 if unsupported
	BTime() time.Time   // birth (created) time, or 0 if unsupported
	CTime() time.Time   // last changed time, or 0 if unsupported
	MTime() time.Time   // last modified time (alias)
	UID() uint64        // user ID, or 0 if unsupported
	GID() uint64        // group ID, or 0 if unsupported
}

A FileInfo describes a file and is returned by Stat. See https://github.com/golang/go/blob/ad7a6f81/src/io/fs/fs.go#L158

func Lstat

func Lstat(name string) (FileInfo, error)

Lstat returns a FileInfo describing the named file. If the file is a symbolic link, the returned FileInfo describes the symbolic link. Lstat makes no attempt to follow the link. If there is an error, it will be of type [*PathError].

On Windows, if the file is a reparse point that is a surrogate for another named entity (such as a symbolic link or mounted folder), the returned FileInfo describes the reparse point, and makes no attempt to resolve it.

func Stat

func Stat(name string) (FileInfo, error)

Stat returns a FileInfo describing the named file. If there is an error, it will be of type [*PathError].

type SupportsType

type SupportsType uint

SupportsType defines a bitmask that identifies if the OS supports specific fields, or not.

const (
	// SupportsLinks defines if the OS supports the Links() field.
	SupportsLinks SupportsType = 1 << iota
	// SupportsATime defines if the OS supports the ATime() (last accessed
	// time) field.
	SupportsATime
	// SupportsBTime defines if the OS supports the BTime() (birth/created
	// time) field.
	SupportsBTime
	// SupportsCTime defines if the OS supports the CTime() (last changed
	// time) field.
	SupportsCTime
	// SupportsUID defines if the OS supports the DeviceUID() field.
	SupportsUID
	// SupportsGID defines if the OS supports the DeviceGID() field.
	SupportsGID
)

Directories

Path Synopsis
main is a sample application that runs functions provided by this library.
main is a sample application that runs functions provided by this library.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL