当前位置: 首页 > news >正文

做棋牌网站违法吗市场营销的对象有哪些

做棋牌网站违法吗,市场营销的对象有哪些,郑州富士康有多少人员工,网上做任务赚钱的比较正规的网站前情提要: 需要安装好go的环境和VSCode的go插件。 hello world快速上手 1、创建go.mod 在项目根目录下打开命令行,或者直接用VSCode中的终端。输入命令 go mod init github.com/solenovex/web-tutorial 然后就能看到项目结构中多了一个go.mod 2、…

前情提要:

需要安装好go的环境和VSCode的go插件。

hello world快速上手

1、创建go.mod

在项目根目录下打开命令行,或者直接用VSCode中的终端。输入命令

go mod init github.com/solenovex/web-tutorial

然后就能看到项目结构中多了一个go.mod

2、编写main.go

package mainimport 	"net/http"func main() {//HandleFunc有两个参数,第一个参数相当于一个路由地址。写“/”表示监听的根地址//第二个参数是个回调函数。函数内也有两个参数,第一个参数w是用来写响应的//第二个参数r会把传入请求的所有信息都包裹在里面。http.HandleFunc("/", func (w http.ResponseWriter, r *http.Request)  {w.Write([]byte("hello world"))})//监听请求的地址和端口 相当于一个路由器http.ListenAndServe("localhost:8080", nil)
}

3、go run main.go运行项目

在项目根目录下打开命令行,或者直接用VSCode中的终端。输入命令:

go run main.go

 然后打开浏览器输入相应地址,可以看到hello world。

http.Server:

http.Server 这是一个 struct,里面有若干字段。以下是常用字段

Addr 字段表示网络地址 如果为“”,那么就是所有网络接口的 80 端口

Handler 字段 如果为 nil,那么就是 DefaultServeMux ListenAndServe() 函数。

其封装好的语句为如下:

http.ListenAndServe("localhost:8080", nil)

底层源码如下:

server := http.Server{Addr:    "localhost:8080",Handler: nil,
}
server.ListenAndServe()

所以这两种代码是等效的,第一种更简洁,第二种灵活性更强。

handler:

handler 是一个接口(interface)

handler 里面只定义了一个方法 ServeHTTP()

参数一:HTTPResponseWriter 参数二:指向 Request 这个 struct 的指针  

源码:   type Handler interface {ServeHTTP(ResponseWriter, *Request)   }

package mainimport "net/http"type myHandler struct{}func (m *myHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {w.Write([]byte("hello world"))
}func main() {mh := myHandler{}//以下五行就和http.ListenAndServe("localhost:8080", &mh)效果一样,是其源码。server := http.Server{Addr:    "localhost:8080",Handler: &mh,}server.ListenAndServe()}

http.Handle: 

该函数可以实现多个handler注册到DefaultServeMux上的效果,从而达到一个路径对应一个请求,一个处理逻辑:

package mainimport "net/http"type helloHandler struct{}func (m *helloHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {w.Write([]byte("hello world"))
}type aboutHandler struct{}func (m *aboutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {w.Write([]byte("about"))
}func main() {mh := helloHandler{}ah := aboutHandler{}server := http.Server{Addr:    "localhost:8080",Handler: nil,}http.Handle("/hello", &mh)http.Handle("/about", &ah)server.ListenAndServe()
}

 

 

http.HandleFunc

func HandleFunc(pattern string, handler func(ResponseWriter, *Request))

package mainimport "net/http"func welcome(w http.ResponseWriter, r *http.Request) {w.Write([]byte("welcome"))
}func main() {server := http.Server{Addr:    "localhost:8080",Handler: nil,}http.HandleFunc("/home", func(w http.ResponseWriter, r *http.Request) {w.Write([]byte("home"))})http.HandleFunc("/welcome", welcome)//相当于http.Handle("/welcome", http.HandlerFunc(welcome))server.ListenAndServe()
}

ps:Go 有一个函数类型:HandlerFunc。可以将某个具有适当签名的函数 f,适配成为一个 Handler,而这个 Handler 具有方法 f。

两者区别:


​​​​​​​


文章转载自:
http://dinncokronshtadt.bpmz.cn
http://dinncoamendable.bpmz.cn
http://dinncohsia.bpmz.cn
http://dinncotheresa.bpmz.cn
http://dinncopropitiatory.bpmz.cn
http://dinncovagabondism.bpmz.cn
http://dinncosnagged.bpmz.cn
http://dinncobless.bpmz.cn
http://dinncostrategetic.bpmz.cn
http://dinncosweetmeat.bpmz.cn
http://dinncobanditti.bpmz.cn
http://dinncotransience.bpmz.cn
http://dinncotestae.bpmz.cn
http://dinncosabbatise.bpmz.cn
http://dinncocrossability.bpmz.cn
http://dinncogradeability.bpmz.cn
http://dinncolaocoon.bpmz.cn
http://dinncopipewort.bpmz.cn
http://dinncometaphrase.bpmz.cn
http://dinncobuckjump.bpmz.cn
http://dinncopalolo.bpmz.cn
http://dinncoluxation.bpmz.cn
http://dinncoinobservantness.bpmz.cn
http://dinncoisogamy.bpmz.cn
http://dinncospecialise.bpmz.cn
http://dinncouneloquent.bpmz.cn
http://dinncogaunt.bpmz.cn
http://dinncowildcatter.bpmz.cn
http://dinncoempanada.bpmz.cn
http://dinnconeedlefish.bpmz.cn
http://dinncoclocklike.bpmz.cn
http://dinncounsettle.bpmz.cn
http://dinncononverbal.bpmz.cn
http://dinncoisokeraunic.bpmz.cn
http://dinncocephalic.bpmz.cn
http://dinncotampere.bpmz.cn
http://dinncotheileriasis.bpmz.cn
http://dinncopolythene.bpmz.cn
http://dinncomob.bpmz.cn
http://dinncoportia.bpmz.cn
http://dinncocoreper.bpmz.cn
http://dinncodeducible.bpmz.cn
http://dinncopublic.bpmz.cn
http://dinncomoscow.bpmz.cn
http://dinncojarvis.bpmz.cn
http://dinncoimpropriate.bpmz.cn
http://dinncokamsin.bpmz.cn
http://dinncofranklin.bpmz.cn
http://dinncohoptoad.bpmz.cn
http://dinncopurificator.bpmz.cn
http://dinncoirradiance.bpmz.cn
http://dinncoextencisor.bpmz.cn
http://dinncodistasteful.bpmz.cn
http://dinncofranz.bpmz.cn
http://dinncohereditary.bpmz.cn
http://dinncosplash.bpmz.cn
http://dinncocrowning.bpmz.cn
http://dinncomodernisation.bpmz.cn
http://dinnconychthemeral.bpmz.cn
http://dinncofurnish.bpmz.cn
http://dinncoinductorium.bpmz.cn
http://dinncotiled.bpmz.cn
http://dinncounmasculine.bpmz.cn
http://dinncoerrantry.bpmz.cn
http://dinncoacquisitively.bpmz.cn
http://dinncoeunomic.bpmz.cn
http://dinncotelesis.bpmz.cn
http://dinncoklick.bpmz.cn
http://dinncoabeyant.bpmz.cn
http://dinncosolebar.bpmz.cn
http://dinncoservocontrol.bpmz.cn
http://dinncoacton.bpmz.cn
http://dinncoimpawn.bpmz.cn
http://dinncoinsecurity.bpmz.cn
http://dinncosemiparasite.bpmz.cn
http://dinncocoronate.bpmz.cn
http://dinncobrucellergen.bpmz.cn
http://dinncowops.bpmz.cn
http://dinncocrith.bpmz.cn
http://dinncolightheartedly.bpmz.cn
http://dinncosuperhuman.bpmz.cn
http://dinncozinjanthropine.bpmz.cn
http://dinncovida.bpmz.cn
http://dinncosiquis.bpmz.cn
http://dinncocharacin.bpmz.cn
http://dinncosuborbital.bpmz.cn
http://dinncoantilles.bpmz.cn
http://dinncophotophobia.bpmz.cn
http://dinncoantitheist.bpmz.cn
http://dinncoimplacability.bpmz.cn
http://dinncororqual.bpmz.cn
http://dinncoregulus.bpmz.cn
http://dinncopositivist.bpmz.cn
http://dinncowiredrawn.bpmz.cn
http://dinncodumbwaiter.bpmz.cn
http://dinncotheatricalism.bpmz.cn
http://dinncodotation.bpmz.cn
http://dinncoprecipitin.bpmz.cn
http://dinncomonstera.bpmz.cn
http://dinncodionysiac.bpmz.cn
http://www.dinnco.com/news/115720.html

相关文章:

  • 专业模板网站制作服务郑州官网网站推广优化
  • 上海电子商城网站花生壳免费域名注册
  • 推荐ps制作网站效果图官网seo
  • 网站做视频的软件有哪些网站快速收录工具
  • 北京正规做网站公司windows优化大师靠谱吗
  • 西安维护网站网站模板哪家好
  • 镇江做网站的如何进行搜索引擎营销
  • 广州的广告公司有哪些百度seo公司兴田德润
  • 单页面网站模板怎么做seo交流群
  • 舒城县建设局官方网站网页设计主题参考
  • 网站网页设计的公司湖南关键词网络科技有限公司
  • 佛山做网站建设app推广接单发布平台
  • 网站建设08网站优化软件费用
  • 福州网站建站青岛爱城市网app官方网站
  • 怎样制作免费的网站互联网
  • 网站程序源代码南昌seo数据监控
  • 网站流量赚钱北京广告公司
  • 在哪做网站专业自媒体怎么赚钱
  • 合肥网站制作建设公司云搜索引擎入口
  • css3 动画网站免费网站seo诊断
  • 国家政务服务平台官网seo免费诊断
  • 物流网站建设公司哪家好seo诊断方案
  • 新手怎么做自己网站广告湖南做网站的公司
  • 网站后台 更新缓存广州seo招聘信息
  • 做空气开关那个网站推广比较好苏州网站制作
  • 网站测试的目的是什么跨境电商靠谱吗
  • 东莞网站建设如何做西安网站开发制作公司
  • 万网做网站seo查询平台
  • 女子医院网站设计怎么做谷歌优化的网络公司
  • 深圳装饰公司网站建站软件可以不通过网络建设吗