1 Star 0 Fork 0

gaogaoss/go-swagger

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
count.go 614 Bytes
一键复制 编辑 原始数据 按行查看 历史
gaogao 提交于 2024-07-30 09:49 . first commit
package biz
import (
"encoding/json"
"fmt"
"io"
"time"
"github.com/go-swagger/go-swagger/examples/stream-server/models"
)
// MyCounter is the concrete implementation
type MyCounter struct{}
// Down is the concrete implementation that spits out the JSON bodies
func (mc *MyCounter) Down(max int64, w io.Writer) error {
if max == 11 {
return fmt.Errorf("we don't *do* elevensies")
}
e := json.NewEncoder(w)
for ix := int64(0); ix <= max; ix++ {
r := max - ix
fmt.Printf("Iteration %d\n", r)
e.Encode(models.Mark{Remains: &r})
if ix != max {
time.Sleep(1 * time.Second)
}
}
return nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gaogaoss/go-swagger.git
git@gitee.com:gaogaoss/go-swagger.git
gaogaoss
go-swagger
go-swagger
da1ca328b83f

搜索帮助