github.com/wangyougui/gf/v2@v2.6.5/frame/gins/gins_httpclient.go (about) 1 // Copyright GoFrame Author(https://goframe.org). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/wangyougui/gf. 6 7 package gins 8 9 import ( 10 "fmt" 11 12 "github.com/wangyougui/gf/v2/internal/instance" 13 "github.com/wangyougui/gf/v2/net/gclient" 14 ) 15 16 // HttpClient returns an instance of http client with specified name. 17 func HttpClient(name ...interface{}) *gclient.Client { 18 var instanceKey = fmt.Sprintf("%s.%v", frameCoreComponentNameHttpClient, name) 19 return instance.GetOrSetFuncLock(instanceKey, func() interface{} { 20 return gclient.New() 21 }).(*gclient.Client) 22 }