Division Operator in C#
Division Operator in C#
Description:
Division Operator in C#
using System; public class Program { public static void Main() { int x = 12; int y = 3; Console.WriteLine(x / y); } }
Output:
4
View On WordPress
seen from Brazil
seen from Lebanon
seen from Malaysia
seen from United States
seen from Russia

seen from United States
seen from Brazil
seen from Australia
seen from United States
seen from Russia

seen from Malaysia
seen from United States
seen from United States

seen from Malaysia

seen from Malaysia

seen from Switzerland
seen from Japan
seen from Malaysia

seen from Brazil

seen from Sweden
Division Operator in C#
Division Operator in C#
Description:
Division Operator in C#
using System; public class Program { public static void Main() { int x = 12; int y = 3; Console.WriteLine(x / y); } }
Output:
4
View On WordPress
Exit Golang Example
Description:
Exit Golang Example
package main import ( "fmt" "os" ) func main() { defer fmt.Println("!") os.Exit(3) }
View On WordPress
Signals Golang Example
Description:
Signals Golang Example
package main import ( "fmt" "os" "os/signal" "syscall" ) func main() { sigs := make(chan os.Signal, 1) done := make(chan bool, 1) signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) go func() { sig :=
View On WordPress
Exec'ing Processes Golang Example
Exec’ing Processes Golang Example
Description:
Exec’ing Processes Golang Example
package main import ( "os" "os/exec" "syscall" ) func main() { binary, lookErr := exec.LookPath("ls") if lookErr != nil { panic(lookErr) } args := []string{"ls", "-a", "-l", "-h"} env := os.Environ() execErr := syscall.Exec(binary, args, env) if execErr != nil { panic(execErr) } }
View On WordPress
Spawning Processes Golang Example
Spawning Processes Golang Example
Description:
Spawning Processes Golang Example
package main import ( "fmt" "io/ioutil" "os/exec" ) func main() { dateCmd := exec.Command("date") dateOut, err := dateCmd.Output() if err != nil { panic(err) } fmt.Println("> date") fmt.Println(string(dateOut)) grepCmd := exec.Command("grep", "hello") grepIn, _ := grepCmd.StdinPipe() grepOut, _ :=…
View On WordPress
HTTP Servers Golang Example
HTTP Servers Golang Example
Description:
HTTP Servers Golang Example
package main import ( "fmt" "net/http" ) func hello(w http.ResponseWriter, req *http.Request) { fmt.Fprintf(w, "hello\n") } func headers(w http.ResponseWriter, req *http.Request) { for name, headers := range req.Header { for _, h := range headers { fmt.Fprintf(w, "%v: %v\n", name, h) } } } func main() { http.HandleFunc("/hello",…
View On WordPress
HTTP Clients Golang Example
HTTP Clients Golang Example
Description:
HTTP Clients Golang Example
package main import ( "bufio" "fmt" "net/http" ) func main() { resp, err := http.Get("http://gobyexample.com") if err != nil { panic(err) } defer resp.Body.Close() fmt.Println("Response status:", resp.Status) scanner := bufio.NewScanner(resp.Body) for i := 0; scanner.Scan() && i < 5; i++ { fmt.Println(scanner.Text()) } if err :=…
View On WordPress
Environment Variables Golang Example
Environment Variables Golang Example
Description:
Environment Variables Golang Example
package main import ( "fmt" "os" "strings" ) func main() { os.Setenv("FOO", "1") fmt.Println("FOO:", os.Getenv("FOO")) fmt.Println("BAR:", os.Getenv("BAR")) fmt.Println() for _, e := range os.Environ() { pair := strings.SplitN(e, "=", 2) fmt.Println(pair[0]) } }
View On WordPress