xgo_cqhttp

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

README

xcaddy - Custom Caddy Builder

This command line tool and associated Go package makes it easy to make custom builds of the go-cqhttp.

Requirements

Install

You can download binaries that are already compiled for your platform from the Release tab.

You may also build xgo-cqhttp from source:

$ go install github.com/RomiChan/xgo-cqhttp/cmd/xgo-cqhttp@latest

Command usage

The xgo-cqhttp command has two primary uses:

  1. Compile custom xgo-cqhttp binaries
  2. A replacement for go run while developing Caddy plugins

The xgo-cqhttp command will use the latest version of Caddy by default. You can customize this for all invocations by setting the GOCQHTTP_VERSION environment variable.

As usual with go command, the xgo-cqhttp command will pass the GOOS, GOARCH, and GOARM environment variables through for cross-compilation.

Custom builds

Syntax:

$ xgo-cqhttp build [<gocq_version>]
    [--output <file>]
    [--with <module[@version][=replacement]>...]
  • <gocq_version> is the core Caddy version to build; defaults to GOCQHTTP_VERSION env variable or latest.
  • --output changes the output file.
  • --with can be used multiple times to add plugins by specifying the Go module name and optionally its version, similar to go get. Module name is required, but specific version and/or local replacement are optional.

Examples:

$ xgo-cqhttp build \
    --with github.com/Mrs4s/go-cqhttp/db/mongodb

$ xgo-cqhttp build v1.0.0-rc1 \
    --with github.com/Mrs4s/go-cqhttp/db/mongodb@v1.0.0-rc1

$ xgo-cqhttp build \
    --with github.com/Mrs4s/MiraiGo=../../my-fork

$ xgo-cqhttp build \
    --with github.com/Mrs4s/MiraiGo@v0.1.1=../../my-fork

You can even replace Caddy core using the --with flag:

$ xcaddy build \
    --with github.com/Mrs4s/go-cqhttp=../../my-caddy-fork

This allows you to hack on go-cqhttp core (and optionally plug in extra modules at the same time!) with relative ease.

© 2020 Matthew Holt

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	Compile
	GoCQHTTPVersion string        `json:"gocq_version,omitempty"`
	Plugins         []Dependency  `json:"plugins,omitempty"`
	Replacements    []Replace     `json:"replacements,omitempty"`
	TimeoutGet      time.Duration `json:"timeout_get,omitempty"`
	TimeoutBuild    time.Duration `json:"timeout_build,omitempty"`
	RaceDetector    bool          `json:"race_detector,omitempty"`
	SkipCleanup     bool          `json:"skip_cleanup,omitempty"`
	SkipBuild       bool          `json:"skip_build,omitempty"`
	Debug           bool          `json:"debug,omitempty"`
}

Builder can produce a custom Caddy build with the configuration it represents.

func (Builder) Build

func (b Builder) Build(ctx context.Context, outputFile string) error

Build builds Caddy at the configured version with the configured plugins and plops down a binary at outputFile.

type Compile

type Compile struct {
	Platform
	Cgo bool `json:"cgo,omitempty"`
}

Compile contains parameters for compilation.

func SupportedPlatforms

func SupportedPlatforms() ([]Compile, error)

SupportedPlatforms runs `go tool dist list` to make a list of possible build targets.

func (Compile) CgoEnabled

func (c Compile) CgoEnabled() string

CgoEnabled returns "1" if c.Cgo is true, "0" otherwise. This is used for setting the CGO_ENABLED env variable.

type Dependency

type Dependency struct {
	// The name (import path) of the Go package. If at a version > 1,
	// it should contain semantic import version (i.e. "/v2").
	// Used with `go get`.
	PackagePath string `json:"module_path,omitempty"`

	// The version of the Go module, as used with `go get`.
	Version string `json:"version,omitempty"`
}

Dependency pairs a Go module path with a version.

type Platform

type Platform struct {
	OS   string `json:"os,omitempty"`
	Arch string `json:"arch,omitempty"`
	ARM  string `json:"arm,omitempty"`
}

Platform represents a build target.

type Replace

type Replace struct {
	// The import path of the module being replaced.
	Old ReplacementPath `json:"old,omitempty"`

	// The path to the replacement module.
	New ReplacementPath `json:"new,omitempty"`
}

Replace represents a Go module replacement.

func NewReplace

func NewReplace(old, new string) Replace

NewReplace creates a new instance of Replace provided old and new Go module paths

type ReplacementPath

type ReplacementPath string

ReplacementPath represents an old or new path component within a Go module replacement directive.

func (ReplacementPath) Param

func (r ReplacementPath) Param() string

Param reformats a go.mod replace directive to be compatible with the `go mod edit` command.

func (ReplacementPath) String

func (r ReplacementPath) String() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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