Uruchamianie za pomocą mojo run
Wykonuj program z wiersza poleceń.
Uruchamianie za pomocą mojo run to bezpłatna lekcja Mojo Academy na CoddyKit. To lekcja 3 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Mojo Academy, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Mojo Academy zawiera 4 lekcji w sumie.
Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.
From File to Running Program
You have a saved hello.mojo file. To see it work, you launch it from your terminal with the mojo command. 🖥️
The mojo run Command
The simplest way to execute a file is mojo run followed by the file name. Mojo compiles and runs it in one step.
mojo run hello.mojoRun from the Right Folder
Open your terminal in the folder that holds the file, or give the full path. Otherwise Mojo cannot find hello.mojo to run.
cd my_project
mojo run hello.mojoSee Your Output
After you press enter, Mojo prints the program's output right in the terminal. Your greeting appears on the next line.
Hello, world!The Shorter Form
You can often drop the word run and just pass the file: mojo hello.mojo does the same thing as mojo run.
mojo hello.mojoEdit, Save, Run Again
Change the code, save, and run the command again to see new output. This quick loop is how you learn fast in Mojo.
Reading an Error Message
If you have a typo, Mojo stops and prints an error with the line number. Read it, fix that line, and run once more.
Run Just Checks for main
mojo run expects your file to have a main function. Without one, it has nothing to start, and you get a clear error.
Building an Executable
For a faster standalone program, mojo build creates an executable file you can run directly, without compiling each time.
mojo build hello.mojorun vs build
Use run while learning and iterating, since it is one quick step. Reach for build when you want a finished binary to ship or reuse.
Your Workflow Is Set
Write code, save the file, type mojo run, read the output. That short cycle is the core habit of every Mojo session.
Quick Check
You want to compile and execute hello.mojo in a single terminal step. Which command does that?
Recap
Use mojo run from the file's folder to compile and execute in one step, read the output, then edit and run again. 🎯
Często zadawane pytania
Czy lekcja „Uruchamianie za pomocą mojo run” jest bezpłatna?
Tak — pełny tekst „Uruchamianie za pomocą mojo run” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Mojo Academy, przejdź na CoddyKit PRO. Kurs Mojo Academy zawiera 4 lekcji w sumie.
Co nauczysz się w „Uruchamianie za pomocą mojo run”?
Wykonuj program z wiersza poleceń. Ćwiczysz Mojo Academy z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.
Czy potrzebuję doświadczenia, aby zacząć Mojo Academy?
Nie wymagamy żadnego doświadczenia. Mojo Academy w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 3 z 4.
Ile czasu zajmuje lekcja „Uruchamianie za pomocą mojo run”?
Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.
Czy mogę pisać i uruchamiać kod w tej lekcji Mojo Academy?
Tak. Każda lekcja Mojo Academy zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.
Wszystkie lekcje w tym kursie
- Pierwszy plik .mojo
- Główny punkt wejścia
- Uruchamianie za pomocą mojo run
- Eksplorowanie w Mojo REPL