当前位置:网站首页>[golang] how to install iris
[golang] how to install iris
2022-06-28 16:24:00 【e1373773】
according to iris stay github Official document on , Combine your own installation process , Now to summarize iris Method of installation .
1. Create a working directory
mkdir myapp2. Enter working directory
cd myapp3. initialization myapp Of mod
go mod init myapp4. from github Get on the iris
go get github.com/kataras/iris/[email protected]- The domestic proxy server may be connected with github Communication failure , So you can change the proxy server .(for Windows10)
go env -w GOPROXY="https://goproxy.io"
5. After installation , Create the first one main.go file
vim main.go6. Write the following code
package main
import (
"github.com/kataras/iris/v12"
)
func main() {
app := iris.New()
// Output html
// Request mode : GET
// Access address : http://localhost:8080/welcome
app.Handle("GET", "/welcome", func(ctx iris.Context) {
ctx.HTML("<h1>Welcome</h1>")
})
// Output string
// Be similar to app.Handle("GET", "/ping", [...])
// Request mode : GET
// Request address : http://localhost:8080/ping
app.Get("/ping", func(ctx iris.Context) {
ctx.WriteString("pong")
})
// Output json
// Request mode : GET
// Request address : http://localhost:8080/hello
app.Get("/hello", func(ctx iris.Context) {
ctx.JSON(iris.Map{"message": "Hello Iris!"})
})
app.Run(iris.Addr(":8080")) //8080 Listening port
}
7. Compile and run main.go
go run main.go8. Open the browser , Input main.go Example in URL
http://localhost:8080/welcome
9. Reference link
边栏推荐
- 3. Caller 服务调用 - dapr
- REDIS00_ Explain redis Conf configuration file
- 使用 Open Connector 进行 HubSpot 和 SAP 系统的集成工作
- Slim gain (sgain) introduction and code implementation -- missing data filling based on generated countermeasure network
- Tiktok actual battle ~ list of bloggers I follow, follow and check
- 关注35岁的坎:畏惧是因为你没有匹配这个年纪该有的能力
- 中能融合携手天翼云打造“能源大脑”
- [recommendation system] esmm model of multi task learning (updating)
- 昨日元宇宙| 沃尔玛成立探索元宇宙和Web3的创新部门,Dior发布元宇宙展览
- IPDK — Overview
猜你喜欢

【Proteus仿真】L297驱动步进电机

3. Caller 服务调用 - dapr

Slim GAIN(SGAIN)介绍及代码实现——基于生成对抗网络的缺失数据填补

among us私服搭建

A 24-year-old bald programmer teaches you how to continuously integrate and deliver microservice delivery. You can't learn how to cut me off
![[proteus simulation] L297 driving stepping motor](/img/12/7902cf31f19df5d2613de7f25dca5b.png)
[proteus simulation] L297 driving stepping motor

Super automation and the future of network security

A new 25K byte from the Department showed me what the ceiling is

Traffic management and control of firewall Foundation

10: 00 interview, came out at 10:02, the question is really too
随机推荐
Ffmpeg forbidden output banner log (30)
【Hot100】1. Sum of two numbers
北京有哪些牛逼的中小型公司?
GAIN的代码实现(4)——基于GAN的Spam数据集缺失数据填补(序)【改进版】
Interviewer: how does the thread pool reuse threads? Do you know? Tell me about it
Summer Challenge ohos build custom service practice
【Hot100】4. Find the median of two positive arrays
wallys/DR7915-wifi6-MT7915-MT7975-2T2R-support-OpenWRT-802.11AX-supporting-MiniPCIe-Module
10:00面试,10:02就出来了 ,问的实在是太...
面试官: 线程池是如何做到线程复用的?有了解过吗,说说看
【力扣】977. 有序数组的平方
如何根据多元索引查询最后一条数据,达到 sql order by desc limit 1的效果呢?
Slim GAIN(SGAIN)介绍及代码实现——基于生成对抗网络的缺失数据填补
ID卡复制教程(使用T5577卡复制4100卡)
【Hot100】1. 两数之和
【Redis】2021/01/31 Redis的简单归纳 No.01
3. Caller 服务调用 - dapr
媒体数据处理V2版本(VPC)图像缩放内容解析
Knowing these commands allows you to master shell's own tools
The future of platform as code is kubernetes extension