[][src]Module genco::prelude::go

Specialization for Go code generation.

Examples

Basic example:

use genco::prelude::*;

let toks: js::Tokens = quote! {
    function foo(v) {
        return v + ", World";
    }

    foo("Hello");
};

assert_eq!(
    vec![
        "function foo(v) {",
        "    return v + \", World\";",
        "}",
        "",
        "foo(\"Hello\");",
    ],
    toks.to_file_vec()?
);

String quoting in JavaScript:

use genco::prelude::*;

let toks: go::Tokens = quote!(#("hello \n world".quoted()));
assert_eq!("\"hello \\n world\"", toks.to_string()?);

Structs

Any

Type that can contain any language type. Derefs to the type trait.

Array

An array []<inner>.

Config

Config data for Go.

Format

Format for Go.

Go

Language specialization for Go.

Interface

The interface type interface{}.

Map

A map map[<key>]<value>.

Type

A Go type.

Enums

AnyRef

Enum that can be used for casting between variants of the same type

Constants

INTERFACE

The interface type interface{}.

Traits

Args

Helper trait for things that can be turned into generic arguments.

TypeTrait

Trait implemented by all types

Functions

array

Setup an array.

imported

Setup an imported element.

local

Setup a local element.

map

Setup a map.

Type Definitions

Tokens

Tokens container specialization for Go.