2022-01-22 15:12:58 +08:00
|
|
|
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
|
|
|
|
//
|
|
|
|
|
// This Source Code Form is subject to the terms of the MIT License.
|
|
|
|
|
// If a copy of the MIT was not distributed with this file,
|
|
|
|
|
// You can obtain one at https://github.com/gogf/gf.
|
|
|
|
|
|
2022-01-22 15:33:31 +08:00
|
|
|
package gtcp_test
|
2022-01-22 15:12:58 +08:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
2022-11-01 20:12:21 +08:00
|
|
|
|
2022-01-22 15:33:31 +08:00
|
|
|
"github.com/gogf/gf/v2/net/gtcp"
|
2022-01-22 15:12:58 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func ExampleGetFreePort() {
|
2022-01-22 15:33:31 +08:00
|
|
|
fmt.Println(gtcp.GetFreePort())
|
2022-01-22 15:12:58 +08:00
|
|
|
|
|
|
|
|
// May Output:
|
|
|
|
|
// 57429 <nil>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func ExampleGetFreePorts() {
|
2022-01-22 15:33:31 +08:00
|
|
|
fmt.Println(gtcp.GetFreePorts(2))
|
2022-01-22 15:12:58 +08:00
|
|
|
|
2022-01-22 15:33:31 +08:00
|
|
|
// May Output:
|
2022-01-22 15:12:58 +08:00
|
|
|
// [57743 57744] <nil>
|
|
|
|
|
}
|