-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
397 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
Go is a tool for managing Go source code. | ||
|
||
Usage: | ||
|
||
go <command> [arguments] | ||
|
||
The commands are: | ||
|
||
bug start a bug report | ||
build compile packages and dependencies | ||
clean remove object files and cached files | ||
doc show documentation for package or symbol | ||
env print Go environment information | ||
fix update packages to use new APIs | ||
fmt gofmt (reformat) package sources | ||
generate generate Go files by processing source | ||
get download and install packages and dependencies | ||
install compile and install packages and dependencies | ||
list list packages or modules | ||
mod module maintenance | ||
run compile and run Go program | ||
test test packages | ||
tool run specified go tool | ||
version print Go version | ||
vet report likely mistakes in packages | ||
|
||
Use "go help <command>" for more information about a command. | ||
|
||
Additional help topics: | ||
|
||
buildconstraint build constraints | ||
buildmode build modes | ||
c calling between Go and C | ||
cache build and test caching | ||
environment environment variables | ||
filetype file types | ||
go.mod the go.mod file | ||
gopath GOPATH environment variable | ||
gopath-get legacy GOPATH go get | ||
goproxy module proxy protocol | ||
importpath import path syntax | ||
modules modules, module versions, and more | ||
module-get module-aware go get | ||
module-auth module authentication using go.sum | ||
module-private module configuration for non-public modules | ||
packages package lists and patterns | ||
testflag testing flags | ||
testfunc testing functions | ||
|
||
Use "go help <topic>" for more information about that topic. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
//Existe tres maneiras de declarar variaveis | ||
var i int = 42 | ||
|
||
var j float32 | ||
j = 45 | ||
|
||
k := 23 | ||
|
||
//Quando nao se atribui valor, o Go automaticamente mete o valor a 0 | ||
var zero int | ||
|
||
fmt.Printf("%v, %T\n", i, i) | ||
fmt.Printf("%v, %T\n", j, j) | ||
fmt.Printf("%v, %T\n", k, k) | ||
fmt.Printf("%v, %T\n", zero, zero) | ||
|
||
//Booleans | ||
var b1 bool | ||
fmt.Printf("%v, %T\n", b1, b1) | ||
|
||
b2 := 4==5 | ||
fmt.Printf("%v, %T\n", b2, b2) | ||
|
||
//Tipos com tamanho | ||
//INT | ||
// var i8 int8 | ||
// var i16 int16 | ||
// var i32 int32 | ||
// var i64 int64 | ||
|
||
//UINT | ||
// var u8 uint8 | ||
// var u16 uint16 | ||
// var u32 uint32 | ||
|
||
//FLOAT | ||
// var f32 float32 | ||
// var f64 float64 | ||
|
||
//COMPLEX | ||
var compl complex64 = 1 + 2i | ||
fmt.Printf("%v, %T\n", compl, compl) | ||
fmt.Printf("%v, %T\n", real(compl), real(compl)) | ||
fmt.Printf("%v, %T\n", imag(compl), imag(compl)) | ||
|
||
var compl2 complex128 = complex(2, 5) | ||
fmt.Printf("%v, %T\n", compl2, compl2) | ||
|
||
|
||
//OPERACOES | ||
a := 10 | ||
b := 5 | ||
|
||
fmt.Println(a+b) | ||
fmt.Println(a*b) | ||
fmt.Println(a/b) | ||
fmt.Println(float32(a/b)) | ||
fmt.Println(a%b) | ||
|
||
//BINARIO | ||
// a: 1010 | ||
// b: 0101 | ||
|
||
fmt.Println(a & b) // AND: 0000 = 0 | ||
fmt.Println(a | b) // OR: 1111 = 15 | ||
fmt.Println(a ^ b) // XOR: 1111 = 15 | ||
fmt.Println(a &^ b)// NOT OR: 0000 = 0 | ||
|
||
//BIT SHIFTING | ||
|
||
c := 8 // 2^3 | ||
|
||
fmt.Println(c << 3) // 2^3 * 2^3 = 2^6 | ||
fmt.Println(c >> 3) // 2^3 / 2^3 = 2^0 | ||
|
||
//STRINGS | ||
var s string = "This is a string" | ||
fmt.Printf("%v, %T\n", s, s) | ||
|
||
fmt.Printf("%v, %T\n", string(s[2]), s[2]) | ||
|
||
s2 := " and this is also a string" | ||
fmt.Printf("%v, %T\n", s+s2, s+s2) | ||
|
||
//Go e como o C em que muda os valores ASCII dos caracters | ||
|
||
by := []byte(s) | ||
//Imprime os valores de cada caracter ASCII em int em formato array | ||
fmt.Printf("%v, %T\n", by, by) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
A lingiuagem go e muito organizada pois mesmo tendo variaveis | ||
a nao serem usadas, para o go sao erros de compilacao. | ||
|
||
variaveis nao podem ser redefinidas na mesma funcao, ou seja: | ||
|
||
package main | ||
|
||
func main(){ | ||
var i int = 56 | ||
|
||
bla bla bla | ||
|
||
var i int = 34 | ||
} | ||
|
||
Na funcao acima o compilador vai dar erro de compilacao |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
syntax = "proto3"; | ||
|
||
package chat; | ||
|
||
message Message { | ||
string body = 1; | ||
} | ||
|
||
service ChatService { | ||
rpc SayHello(Message) returns (Message) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package chat | ||
|
||
import ( | ||
"log" | ||
|
||
"golang.org/x/net/context" | ||
|
||
) | ||
|
||
type Server struct { | ||
} | ||
|
||
func (s *Server) SayHello(ctx context.Context, message *Message) (*Message, error) { | ||
|
||
log.Printf("Received message body from client: %s", message.Body) | ||
|
||
return &Message{Body: "Hello From the Server!"}, nil | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.