mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
docs: mention v run
and v symlink
earlier
This commit is contained in:
parent
bb9d268bd9
commit
b17e10c72e
29
README.md
29
README.md
@ -49,10 +49,14 @@ cd v
|
|||||||
make
|
make
|
||||||
```
|
```
|
||||||
|
|
||||||
That's it! Now you have a V executable at `[path to V repo]/v`. `[path to V repo]` can be anywhere.
|
That's it! Now you have a V executable at `[path to V repo]/v`.
|
||||||
|
`[path to V repo]` can be anywhere.
|
||||||
|
|
||||||
(On Windows `make` means running `make.bat`, so make sure you use `cmd.exe`.)
|
(On Windows `make` means running `make.bat`, so make sure you use `cmd.exe`.)
|
||||||
|
|
||||||
|
After the above, you can try doing: `./v run examples/hello_world.v` on Unix,
|
||||||
|
or `.\v.exe run examples\hello_world.v` on Windows.
|
||||||
|
|
||||||
V is being constantly updated. To update V, simply run:
|
V is being constantly updated. To update V, simply run:
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -71,12 +75,33 @@ Otherwise, follow these instructions:
|
|||||||
|
|
||||||
### Symlinking
|
### Symlinking
|
||||||
|
|
||||||
You can create a `/usr/local/bin/v` symlink so that V is globally available:
|
NB: it is *highly recommended*, that you put V on your PATH. That saves
|
||||||
|
you the effort to type in the full path to your v executable everytime.
|
||||||
|
V provides a convenience `v symlink` command to do that more easily.
|
||||||
|
|
||||||
|
On Unix systems, it creates a `/usr/local/bin/v` symlink to your
|
||||||
|
executable. To do that, run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo ./v symlink
|
sudo ./v symlink
|
||||||
```
|
```
|
||||||
|
|
||||||
|
On Windows, start a new shell with administrative privileges, for
|
||||||
|
example by <Windows Key>, then type cmd.exe, right click on its menu
|
||||||
|
entry, and choose `Run as administrator`. In the new administrative
|
||||||
|
shell, cd to the path, where you have compiled v.exe, then type:
|
||||||
|
```bat
|
||||||
|
.\v.exe symlink`
|
||||||
|
```
|
||||||
|
That will make v available everywhere, by adding it to your PATH.
|
||||||
|
Please restart your shell/editor after that, so that it can pick
|
||||||
|
the new PATH variable.
|
||||||
|
|
||||||
|
NB: there is no need to run `v symlink` more than once - v will
|
||||||
|
continue to be available, even after `v up`, restarts and so on.
|
||||||
|
You only need to run it again, if you decide to move the V repo
|
||||||
|
folder somewhere else.
|
||||||
|
|
||||||
### Docker
|
### Docker
|
||||||
|
|
||||||
<details><summary>Expand Docker instructions</summary>
|
<details><summary>Expand Docker instructions</summary>
|
||||||
|
16
doc/docs.md
16
doc/docs.md
@ -91,10 +91,20 @@ fn main() {
|
|||||||
println('hello world')
|
println('hello world')
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Save that snippet into a file `hello.v` . Now do: `v run hello.v` .
|
||||||
|
|
||||||
Functions are declared with `fn`. The return type goes after the function
|
(That is assuming you have symlinked your V with `v symlink`, as described here
|
||||||
name. In this case `main` doesn't return anything, so the return type can be
|
[Symlinking](https://github.com/vlang/v/blob/master/README.md#symlinking).
|
||||||
omitted.
|
If you have not yet, you have to type the path to v/v.exe manually.)
|
||||||
|
|
||||||
|
Congratulations - you just wrote your first V program, and executed it!
|
||||||
|
|
||||||
|
(You can compile a program without execution, with: `v hello.v`.
|
||||||
|
See `v help` for all supported commands)
|
||||||
|
|
||||||
|
In the above example, you can see that functions are declared with `fn`.
|
||||||
|
The return type goes after the function name. In this case `main` doesn't
|
||||||
|
return anything, so the return type can be omitted.
|
||||||
|
|
||||||
As in many other languages (such as C, Go and Rust), `main` is an entry point.
|
As in many other languages (such as C, Go and Rust), `main` is an entry point.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user