phantom

package module
v0.0.0-...-f1bf37d Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: MIT Imports: 6 Imported by: 0

README

phantomPkgGoDev

[!WARNING] phantom is currently in experimental. Breaking changes may occur.

phantom checks assignabillity of type arguments of phantom type parameter with type alias as folowing codes.

type UUID[T any] = uuid.UUID

type Organization struct {
    OrganizationID UUID[Organization]
    // ...
}

type User struct {
    OrganizationID  UUID[Organization]
    UserID          UUID[User]
    // ...
}

func getUser(orgID UUID[Organization], userID UUID[User]) (*User, error) {
    // ...
}

func run() error {
    var userID UUID[UserID]         // = ...
    var orgID UUID[OrganizationID]  // = ...

    user, err := getUser(userID, orgID) // type checking does not report error but phantom reports error
    // ...
}

See tests.

License

This project is licensed under the MIT License.

Contributions are always welcome! Feel free to open issues or PRs for bugs and enhancements.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AssignableAnalyzer = &analysis.Analyzer{
	Name: "assignable",
	Doc:  doc,
	Run:  run,
	Requires: []*analysis.Analyzer{
		inspect.Analyzer,
	},
}

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd
phantom command

Jump to

Keyboard shortcuts

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