Source File
migration.go
Belonging Package
github.com/golang-migrate/migrate/v4
package migrate
import (
)
var DefaultBufferSize = uint(100000)
func ( io.ReadCloser, string,
uint, int) (*Migration, error) {
:= time.Now()
:= &Migration{
Identifier: ,
Version: ,
TargetVersion: ,
Scheduled: ,
}
if == nil {
if len() == 0 {
.Identifier = "<empty>"
}
.StartedBuffering =
.FinishedBuffering =
.FinishedReading =
return , nil
}
, := io.Pipe()
.Body = // want to simulate low latency? newSlowReader(body)
.BufferSize = DefaultBufferSize
.BufferedBody =
.bufferWriter =
return , nil
}
func ( *Migration) () string {
return fmt.Sprintf("%v [%v=>%v]", .Identifier, .Version, .TargetVersion)
}
func ( *Migration) () string {
:= "u"
if .TargetVersion < int(.Version) {
= "d"
}
return fmt.Sprintf("%v/%v %v", .Version, , .Identifier)
}
func ( *Migration) () error {
if .Body == nil {
return nil
}
.StartedBuffering = time.Now()
:= bufio.NewReaderSize(.Body, int(.BufferSize))
if , := .Peek(int(.BufferSize)); != nil && != io.EOF {
return
}
.FinishedBuffering = time.Now()
, := .WriteTo(.bufferWriter)
if != nil {
return
}
.FinishedReading = time.Now()
.BytesRead =
if := .bufferWriter.Close(); != nil {
return
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |