Upload local source code to micro server (#1613)

This commit is contained in:
Janos Dobronszki
2020-05-13 12:07:53 +02:00
committed by GitHub
parent 116cc1e9ee
commit 0fb4734e67
5 changed files with 186 additions and 70 deletions

View File

@@ -35,7 +35,11 @@ type handler struct {
func (h *handler) Open(ctx context.Context, req *proto.OpenRequest, rsp *proto.OpenResponse) error {
path := filepath.Join(h.readDir, req.Filename)
file, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR, 0666)
flags := os.O_CREATE | os.O_RDWR
if req.GetTruncate() {
flags = flags | os.O_TRUNC
}
file, err := os.OpenFile(path, flags, 0666)
if err != nil {
return errors.InternalServerError("go.micro.server", err.Error())
}