Skip to main content

Crate goish

Crate goish 

Source

Re-exports§

pub use encoding::base64;
pub use encoding::binary;
pub use encoding::csv;
pub use encoding::hex;
pub use encoding::json;
pub use math::rand;
pub use net::http;
pub use net::url;
pub use os::exec;
pub use path::filepath;
pub use unicode::utf8;
pub use crate::types::*;

Modules§

bufio
bytes
chan
cmp
cmp: Go’s cmp package — ordered comparison helpers.
consts
container
context
crypto
defer
encoding
errors
flag
fmt
goroutine
gostring
hash
html
html: Go’s html package — EscapeString / UnescapeString.
io
iter
iter: Go 1.23’s iter package — generic sequence iterators.
log
maps
maps: Go’s maps package — generic map operations.
math
mime
net
os
path
prelude
range
regexp
runtime
slices
slices: Go’s slices package — generic slice operations.
sort
strconv
strings
sync
testing
text
time
types
unicode

Macros§

Const
Const!{} — Go-style constant block with iota.
Cookie
Go-shape Cookie literal.
Enum
Errorf
fmt.Errorf(format, args…) — returns an error with the formatted message. Supports %w to wrap a single error; its .Error() text replaces the verb at format time, and the returned error unwraps to the original.
Fprintf
fmt.Fprintf(w, format, args…) — writes to anything that impls io::Write. Returns (int, error).
IntNewtype
IntNewtype!(ID = uint64) — Go’s type ID uint64.
MailAddress
Go-shape mail.Address{Name: "…", Address: "…"} literal. Accepts string literals without .into() noise.
Printf
fmt.Printf(format, args…) — Go-style verbs. Returns (int, error).
Println
fmt.Println(a, b, c) — space-separated, trailing newline. Returns (int, error).
SliceNewtype
SliceNewtype!(IDSlice = ID) — Go’s type IDSlice []ID.
Sprintf
fmt.Sprintf(format, args…) — returns the formatted string.
Struct
Type
Type!(Name = <shape>) — Go’s type Name <shape> decl.
append
append!(s, x, y, z) — Go’s append(s, ...) for slices.
benchmark
benchmark!{ fn BenchmarkX(b) { … } } — registers a benchmark as a regular #[test].
cap
cap!(x) — Go’s polymorphic cap() builtin.
cat
Variadic concatenation. Single allocation.
chan
chan!(T) → unbuffered channel (rendezvous) chan!(T, n) → buffered channel with capacity n
clone_trait_object
Emits impl Clone for Box<dyn Trait> for the given trait. The trait must have DynClone as a supertrait.
close
close!(&ch) — Go’s close(ch).
copy
copy!(dst, src) — Go’s copy(dst, src) int builtin.
defer
defer!{ stmts } — run stmts at the end of the enclosing scope.
delete
delete!(m, k) — Go’s delete(m, k) builtin for maps.
go
go!{ stmts } — spawn a goroutine running the block.
len
len!(x) — Go’s polymorphic len() builtin.
log_Fatalf
log.Fatalf — like Printf, but then os.Exit(1).
log_Panic
log.Panic — like Printf, but then panic!.
log_Printf
log.Printf(fmt, …) — Go-style verbs, written to stderr with timestamp.
log_Println
log.Println(a, b, c) — space-separated, newline-terminated, stderr.
make
make!(...) — Go’s make() builtin: allocate empty/sized container.
map
Two forms — pick the one closest to your Go original:
range
range!(xs) — Go’s for i, v := range xs as a Rust iterator.
recover
recover!{ body } — runs body; if it panics, captures the panic message as Some(String). If it completes normally, returns None.
select
select!{ ... } — Go’s select statement (proc-macro form).
slice
Three forms — pick the one closest to your Go original:
string
string!("literal") — lazy-initialized module-scoped string.
stringer
Generate Stringer + Display + an inherent String() method from one Go-style block.
test
test!{ fn TestFoo(t) { … } } — declares a #[test] test function whose body gets a &T named t. Fatal/Skip/FailNow unwind via a sentinel panic which the macro catches and converts to a PASS/FAIL/SKIP result.
test_h
test_h!{ fn TestX(t) { … } } — variant for custom-harness test files (harness = false). Emits a plain function + an inventory registration so test_main!’s generated main() can discover and run it via m.Run().
test_main
test_main!{ fn TestMain(m) { … } } — generate a Go-shape TestMain.
var
var! — Go’s var keyword for lazy-initialized module-level values.

Traits§

DynClone
Supertrait that lets a trait object be cloned. Any type that impls Clone automatically impls DynClone via a blanket impl.