File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,10 +4,13 @@ import (
44 "bytes"
55 "fmt"
66 "log"
7+ "os"
78 "os/exec"
89)
910
1011// Exec - Start a command on system
12+ // Original : https://www.php.net/manual/tr/function.exec.php
13+ // exec() executes the given command.
1114func Exec (of string ) {
1215 var out bytes.Buffer
1316 cmd := exec .Command (of )
@@ -18,7 +21,9 @@ func Exec(of string) {
1821 }
1922}
2023
21- // ShellExec - Start a command on system
24+ // ShellExec - Execute command via shell and return the complete output as a string
25+ // Original : https://www.php.net/manual/en/function.shell-exec.php
26+ // This function is identical to the backtick operator.
2227func ShellExec (of string ) {
2328 var out bytes.Buffer
2429 cmd := exec .Command (of )
@@ -29,3 +34,17 @@ func ShellExec(of string) {
2934 }
3035 fmt .Printf ("%q\n " , out .String ())
3136}
37+
38+ // Exit - Output a message and terminate the current script
39+ // Original : https://www.php.net/manual/en/function.exit.php
40+ // Terminates execution of the script. Shutdown functions and object destructors will always be executed even if exit is called.
41+ func Exit (of int ) {
42+ os .Exit (of )
43+ }
44+
45+ // Die - Equivalent to exit
46+ // Original : https://www.php.net/manual/en/function.die.php
47+ // This language construct is equivalent to exit().
48+ func Die (of int ) {
49+ os .Exit (of )
50+ }
Original file line number Diff line number Diff line change @@ -8,24 +8,28 @@ import "time"
88
99// Time - Similar function of time() in PHP.
1010// Original : https://www.php.net/manual/en/function.time.php
11+ // Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).
1112func Time () int64 {
1213 return time .Now ().Unix ()
1314}
1415
1516// Now - Similar function of time() in PHP.
1617// Original : https://www.php.net/manual/en/function.time.php
18+ // Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).
1719func Now () int64 {
1820 return time .Now ().Unix ()
1921}
2022
2123// Sleep - Delay in seconds
2224// Original : https://www.php.net/manual/en/function.sleep.php
25+ // Delays the program execution for the given number of seconds.
2326func Sleep (t int64 ) {
2427 time .Sleep (time .Duration (t ) * time .Second )
2528}
2629
2730// USleep - Delay in microseconds
2831// Original : https://www.php.net/manual/en/function.usleep.php
32+ // Delays program execution for the given number of microseconds.
2933func USleep (t int64 ) {
3034 time .Sleep (time .Duration (t ) * time .Microsecond )
3135}
You can’t perform that action at this time.
0 commit comments