index
This commit is contained in:
parent
e4b083d49b
commit
d7045c962c
@ -1,13 +0,0 @@
|
|||||||
// ## Reading Input
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
fmt.Print("Enter a number: ")
|
|
||||||
var input float64
|
|
||||||
fmt.Scanf("%f", &input)
|
|
||||||
output := input * 2
|
|
||||||
fmt.Println(input, "* 2 =", output)
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
$ go run reading-input.go
|
|
||||||
Enter a number: 7
|
|
||||||
7 * 2 = 14
|
|
@ -1,26 +0,0 @@
|
|||||||
// ## TCP Server
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import "net"
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
listener, _ := net.Listen("tcp", "0.0.0.0:5000")
|
|
||||||
for {
|
|
||||||
conn, _ := listener.Accept()
|
|
||||||
go Serve(conn)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Serve(conn net.Conn) {
|
|
||||||
buf := make([]byte, 1024)
|
|
||||||
for {
|
|
||||||
_, err := conn.Read(buf)
|
|
||||||
if err != nil {
|
|
||||||
conn.Close()
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
conn.Write(buf)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
$ go run tcp-server.go
|
|
@ -69,10 +69,11 @@ urls
|
|||||||
sha1-hashes
|
sha1-hashes
|
||||||
~ base64-encoding
|
~ base64-encoding
|
||||||
|
|
||||||
# systems programming
|
# systems libraries
|
||||||
reading-files
|
reading-files
|
||||||
writing-files
|
writing-files
|
||||||
~ standard-streams
|
~ standard-streams
|
||||||
|
line-filter
|
||||||
command-line-arguments
|
command-line-arguments
|
||||||
command-line-flags
|
command-line-flags
|
||||||
environment-variables
|
environment-variables
|
||||||
@ -80,9 +81,6 @@ spawning-processes
|
|||||||
execing-processes
|
execing-processes
|
||||||
signals
|
signals
|
||||||
exit
|
exit
|
||||||
reading-input
|
|
||||||
line-filter
|
|
||||||
tcp server
|
|
||||||
|
|
||||||
# client libraries
|
# client libraries
|
||||||
tcp-client
|
tcp-client
|
||||||
|
Loading…
x
Reference in New Issue
Block a user