Little experience: go match multi-line strings, range usage and close the channel usage

  • go regular regular expression matching a plurality of lines of the string

(?s)\d+\)\s.*?\n\s*\n
`
1) 初始化页面元素未达到要求
  - Expected false
  - Failed: No 

2) 初始化页面元
  - Failed: No element found

3) 初始页e多行本框好
  - Expected fa
  - Failed: No element found using locator: By(

`
  • Note the use of the channel range

cha := make(chan int,10)
for data:=range cha{
    // 只有close的时候range才不会继续循环获取管道数据
    fmt.Println(data)
}

This code will complain because the cha no input data, the data is read deadlock. Modify the code as follows:

cha := make(chan int,10)
close(cha)
for data:=range cha{
    // 只有close的时候range才不会继续循环获取管道数据
    fmt.Println(data)
}

When the channel is closed, when no data is no longer read data pipe

  • The channel close () Use: Because after closing, <- channel the output result, this feature can be made by Sentinel coroutine

Guess you like

Origin www.cnblogs.com/MyUniverse/p/11669095.html