Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

helloworld

package main

import "fmt"

func main() {
   fmt.Printf("hello, world\n")
}

MAIN

package main

import "fmt"

func main() {
   var x float64
   x = 20.0
   fmt.Println(x)
   fmt.Printf("x is of type %T\n", x)
}

是的发送地方

package main

import "fmt"

func main() {
   fmt.Printf("hello, world\n")
}

zdvzd

package main

import "fmt"

func main() {
   /* local variable definition */
   var a int = 100
   var b int = 200

   fmt.Printf("Before swap, value of a : %d\n", a )
   fmt.Printf("Before swap, value of b : %d\n", b )

   /* calling a function to swap the values */
   swap(&a, &b)

   fmt.Printf("After swap, value of a : %d\n", a )
   fmt.Printf("After swap, value of b : %d\n", b )
}
func swap(x *int, y *int) {
   var temp int

   temp = *x /* save the value of x */
   *x = *y    /* put y into x */
   *y = temp /* put temp into y */

  // return temp;
}

https://outlook.live.com/owa/?path=/mail/inbox

package main

import "fmt"

func main() {
   fmt.Printf("hello, world\n")
}

loop

package main

import "fmt"

func main() {

  for j :=0; j < 10; j++ {
       fmt.Println("This loop will run 10 times.\n");
   
       
   }
   
  sum := 0
	for i := 0; i < 10; i++ {
		sum += i
	} 
	fmt.Println(sum)
}

Execute GO Language Online

package main


import (
	"encoding/json"	
	"fmt"
	"strings"
	"net/url"

)

func main() {

allowListsFile := `{ 
"allow_these_domains": ["veofdua"], 
"allow_subdomains_on":["veofdua2"], 
"blocked_domains":["veofdua3","veofdua4"]}`


	am, err := loadAllowMaps(allowListsFile)
	if err != nil {
		fmt.Printf("unable to reload allowlists at %#v: %s", allowListsFile, err)
	
	}
		for key, value := range am.AllowTheseDomains {
		    _, fullDomain, _r := effectiveDomain(key)
		    fmt.Println("Key:", key, "Value:", value, "result: ", fullDomain)
		    
		}
			for key, value := range am.AllowSubdomainsOn {
		    fmt.Println("Key:", key, "Value:", value)
		    
		}
			for key, value := range am.BlockedDomains {
		    fmt.Println("Key:", key, "Value:", value)
		    
		}

}

type allowLists struct {
	AllowTheseDomains []string `json:"allow_these_domains"`
	AllowSubdomainsOn []string `json:"allow_subdomains_on"`
	BlockedDomains    []string `json:"blocked_domains"`
}


type allowMaps struct {
	AllowTheseDomains map[string]bool
	AllowSubdomainsOn map[string]bool
	BlockedDomains    map[string]bool
}

func loadAllowMaps(fp string) (*allowMaps, error) {
    
    fmt.Println("json", fp)
    
   al := &allowLists{}
   json.Unmarshal([]byte(fp), &al)


	am := &allowMaps{
		AllowTheseDomains: make(map[string]bool, len(al.AllowTheseDomains)),
		AllowSubdomainsOn: make(map[string]bool, len(al.AllowSubdomainsOn)),
		BlockedDomains:    make(map[string]bool, len(al.BlockedDomains)),
	}
	
	fmt.Println("AllowTheseDomains", len(al.AllowTheseDomains))
	fmt.Println("AllowSubdomainsOn", len(al.AllowSubdomainsOn))
	fmt.Println("BlockedDomains", len(al.BlockedDomains))
	
    for _, dom := range al.AllowTheseDomains {
		am.AllowTheseDomains[dom] = true
	}
	for _, dom := range al.AllowSubdomainsOn {
		am.AllowSubdomainsOn[dom] = true
	}
	for _, dom := range al.BlockedDomains {
		am.BlockedDomains[dom] = true
	}
	
	return am, nil
}

func effectiveDomain(str string) (string, string, error) {
	if str == "localhost" {
		return "localhost", "localhost", nil
	}
	u, err := url.Parse(str)
	if err != nil {
		return "", "", err
	}
	host := u.Host
	if host == "" {
		return "", "", fmt.Errorf("unparsable domain string %#v", str)
	}
	i := strings.Index(host, ":")
	if i >= 0 {
		host = host[:i]
	}
	if host == "localhost" {
		return "localhost", "localhost", nil
	}
	d, err := publicsuffix.EffectiveTLDPlusOne(host)
	if err != nil {
		return "", "", err
	}
	return d, host, nil
}


Hello

package main

import "fmt"

func main() {
    for i:=1 ; i<5 ; i++ {
         for j:=1 ; j<=i*2-1 ; j++ {
            fmt.Print("*")
             
         }
         fmt.Println()
    }
}

jfrghdedcv

package main

import "fmt"





fgff

package main

import "fmt"

func main() {
   /* local variable definition */
   var a int = 100
   var b int = 200

   fmt.Printf("Before swap, value of a : %d\n", a )
   fmt.Printf("Before swap, value of b : %d\n", b )

   /* calling a function to swap the values */
   swap(a, b)

   fmt.Printf("After swap, value of a : %d\n", a )
   fmt.Printf("After swap, value of b : %d\n", b )
}
func swap(x, y int) int {
   var temp int

   temp = x /* save the value of x */
   x = y    /* put y into x */
   y = temp /* put temp into y */

   return temp;
}

Previous 1 ... 5 6 7 8 9 10 11 ... 17 Next
Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.