E4068#
Main function is already defined.
In MoonBit, a main package contains a single main function that serves as
the entry point of the program. Therefore, you cannot define more than one
main function in the main package. If you want to have multiple programs to be
built as separate binaries, you can use multiple main packages within the same
module.
Erroneous example#
Suppose in package main:
main/moon.pkg:
options(
"is-main": true,
)
main/main.mbt:
///|
fn main {
println("Hello, World!")
}
///|
fn main {
println("Hello, World! Again!")
}
Suggestion#
You can either remove the extra main function:
///|
fn main {
println("Hello, World!")
}
Or you can move the extra main function to a different package, say main2:
main2/moon.pkg:
options(
"is-main": true,
)
main2/main.mbt:
///|
fn main {
println("Hello, World! Again!")
}
while keeping main/main.mbt with only one main function:
///|
fn main {
println("Hello, World!")
}