Documentation
¶
Overview ¶
Package solc provides functionality related to the Solidity compiler (solc).
The solc package provides a Go interface to manage Solidity compiler versions using solc-select, allowing for the installation, switching, and querying of available compiler versions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Commander ¶
type Commander interface {
Current() string
Install(version string) (bool, []string, error)
Use(version string) (bool, []string, []string, error)
Versions() ([]Version, error)
Upgrade() (bool, error)
}
Commander interface defines the methods for executing solc-select commands.
type MockCommand ¶
type MockCommand struct {
// contains filtered or unexported fields
}
MockCommand provides a mock implementation of the Commander interface. It simulates the behavior of solc-select commands for testing purposes.
func (*MockCommand) Current ¶
func (mc *MockCommand) Current() string
Current returns the current version of solc in use in the mock environment.
func (*MockCommand) Install ¶
func (mc *MockCommand) Install(version string) (bool, []string, error)
Install simulates the installation of a specific version of solc. If the version is "0.8.19", it simulates a successful installation. Otherwise, it simulates an installation error.
func (*MockCommand) Upgrade ¶
func (mc *MockCommand) Upgrade() (bool, error)
Upgrade simulates the process of upgrading to the latest version of solc. In this mock implementation, it always simulates a successful upgrade.
func (*MockCommand) Use ¶
Use simulates the process of switching to a specific version of solc. If the version is "0.8.19", it simulates a successful switch. Otherwise, it simulates an error in switching.
func (*MockCommand) Versions ¶
func (mc *MockCommand) Versions() ([]Version, error)
Versions simulates the retrieval of available solc versions. It returns a predefined list of versions for testing purposes.
type RealCommand ¶
type RealCommand struct {
// contains filtered or unexported fields
}
RealCommand implements the Commander interface using real solc-select commands.
func (*RealCommand) Current ¶
func (rc *RealCommand) Current() string
Current returns the current version of solc in use.
func (*RealCommand) Install ¶
func (rc *RealCommand) Install(version string) (bool, []string, error)
Install a specific version of solc. Returns a boolean indicating if the version was installed, a slice of output lines from solc-select, and an error if any occurred.
func (*RealCommand) Upgrade ¶
func (rc *RealCommand) Upgrade() (bool, error)
Upgrade to the latest version of solc. Returns a bool indicating if solc-select is up to date, and an error if any occurred.
func (*RealCommand) Use ¶
Use a specific version of solc. If the version does not exist, install it. Returns a boolean indicating success, the outputs from the install and use commands, and an error if any occurred.
func (*RealCommand) Versions ¶
func (rc *RealCommand) Versions() ([]Version, error)
Versions lists all available versions of solc using solc-select.
type Select ¶
type Select struct {
// contains filtered or unexported fields
}
Select represents a utility structure that manages the version of solc in use. It encapsulates the current version of solc and provides functionalities to interact with solc-select.
func NewSelect ¶
NewSelect initializes and returns a new instance of the Select struct. The function performs the following steps: 1. Checks if solc-select is installed on the system. 2. If solc-select is not installed, it returns an error. 3. If solc-select is installed, the function fetches the list of available solc versions. 4. Identifies the currently active solc version and sets it in the returned Select struct. 5. Checks if a Python virtual environment is set and initializes the current solc version. If any of the above steps fail, an error is returned.
func (*Select) Install ¶
Install a specific version of solc. Returns a boolean indicating if the version was installed, a slice of output lines from solc-select, and an error if any occurred.
func (*Select) Upgrade ¶
Upgrade to the latest version of solc. Returns a bool indicating if solc-select is up to date, and an error if any occurred.