Re: [go-nuts] The effect go test -v flag on local directory mode and package list mode

2022-10-12 Thread jingguo yao
Got it. On Thu, Oct 13, 2022 at 7:13 AM Ian Lance Taylor wrote: > On Tue, Oct 11, 2022 at 8:42 PM Jingguo Yao wrote: > > > > I have the following directory layout: > > > > ├── bar > > │ └── bar_test.go > > ├── foo > > │ └── foo_test.go > >

[go-nuts] The effect go test -v flag on local directory mode and package list mode

2022-10-11 Thread Jingguo Yao
I have the following directory layout: ├── bar │ └── bar_test.go ├── foo │ └── foo_test.go ├── go.mod └── go.sum foo_test.go: package main import ( "fmt" "testing" ) func TestHelloWorld(t *testing.T) { fmt.Println("hello, foo") t.Log("hi, foo") } bar_test.go: package bar

[go-nuts] Confusion about the doc for ServeMux

2020-05-14 Thread Jingguo Yao
https://golang.org/pkg/net/http/#ServeMux says: > Host-specific patterns take precedence over general patterns, so that a handler might register for the two patterns "/codesearch" and "codesearch.google.com/" without also taking over requests for "http://www.google.com/";. 1. "/codesearch

[go-nuts] Methods to serve static files under a path other than the root

2020-05-11 Thread Jingguo Yao
The following code serves the files inside ./data directory on localhost:8080/: log.Fatal(http.ListenAndServe(":8080", http.FileServer(http.Dir("./data" The following code does the same: http.Handle("/", http.FileServer(http.Dir("./data"))) log.Fatal(http.ListenAndServe(":8080", nil)) T

Re: [go-nuts] How is a for loop preempted in Go?

2019-02-23 Thread Jingguo Yao
rite > code that acts like that's true and never see a problem -- but the > reality of the implementation is that right now it is possible to > tight-loop and block other goroutines. > > -Ian > > Quoting Jingguo Yao (2019-02-22 03:31:55) > >Yes, my fault. Than

Re: [go-nuts] How is a for loop preempted in Go?

2019-02-22 Thread Jingguo Yao
count) // goroutine 1 go func() { for { } }() // goroutine 2 go func() { for { } }() time.Sleep(10 * time.Second) } Can goroutine 1 or goroutine 2 be preempted? If yes, by which mechanism? On Friday, February 22, 2019 at 4:20:12 PM UTC+8, Ian Denhardt wrote: > > Quoting Jingguo Yao (2019

[go-nuts] How is a for loop preempted in Go?

2019-02-22 Thread Jingguo Yao
Consider the following code which launches two goroutines. Each goroutine uses a for loop to print messages. package main import ( "fmt" "runtime" "time" ) func main() { count := runtime.GOMAXPROCS(1) fmt.Printf("GOMAXPROCS: %d\n", count) // goroutine 1 go func() { for

[go-nuts] How to do a cleanup of context cancelling?

2019-02-14 Thread Jingguo Yao
https://blog.golang.org/context uses the following code to cancel the request if ctx.Done is closed before the goroutine exits: func httpDo(ctx context.Context, req *http.Request, f func(*http.Response, error) error) error { // Run the HTTP request in a goroutine and pass the response to f.

[go-nuts] A question about the description of sync.Pool.Get

2017-10-26 Thread jingguo yao
Can anyone explain the meaning of " Get may choose to ignore the pool and treat it as empty." in https://golang.org/pkg/sync/#Pool.Get? > Get selects an arbitrary item from the Pool, removes it from the Pool, and returns it to the caller. Get may choose to ignore the pool and treat it as empty. Ca

Re: [go-nuts] How does iota affect the types of the subsequent constants in a constant declaration?

2016-07-03 Thread Jingguo Yao
Matt: Thanks for you confirmation. -- Jingguo -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit

[go-nuts] How does iota affect the types of the subsequent constants in a constant declaration?

2016-07-03 Thread Jingguo Yao
Take the following code as an example: package main import ( "fmt" ) const ( First int64 = iota Second ) const ( One int64 = 1 Two = 2 ) func main() { fmt.Printf("First type: %T, Second type: %T\n", First, Second) fmt.Printf("One type: %T, Two type: %T\n", One, Two) } Running the

Re: [go-nuts] Where can I find the format definition of stack trace?

2016-06-29 Thread jingguo yao
Aram: Ok, Thanks. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/o

Re: [go-nuts] Where can I find the format definition of stack trace?

2016-06-29 Thread Jingguo Yao
Aram: Thanks for your reply. Could you point out where you find the format information? -- Jingguo -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+

[go-nuts] Where can I find the format definition of stack trace?

2016-06-28 Thread Jingguo Yao
Invoking https://golang.org/pkg/runtime/debug/#PrintStack produces the following result: goroutine 35 [running]: runtime/debug.Stack(0x0, 0x0, 0x0) /usr/local/go/src/runtime/debug/stack.go:24 +0x80 runtime/debug.PrintStack() /usr/local/go/src/runtime/debug/stack.go:16 +0x18 github.