Пример #1
0
// Run tries to be short.
func (task Dummy) Run() error {
	file := dagger.Output(task).MustCreateLocalTarget()
	defer file.Close()
	for _, p := range dagger.Input(task).PathList() {
		if _, err := io.WriteString(file, fmt.Sprintf("OK\t%s\n", p)); err != nil {
			return err
		}
	}
	return nil
}
Пример #2
0
func (task BogusAggregation) Run() error {
	scanner, err := dagger.Input(task).Scanner()
	if err != nil {
		return err
	}
	var sum int
	for scanner.Scan() {
		fields := strings.Fields(scanner.Text())
		v, err := strconv.Atoi(fields[task.Col])
		if err != nil {
			return err
		}
		sum += v
	}
	file, err := dagger.Output(task).CreateLocalTarget()
	if err != nil {
		return err
	}
	defer file.Close()
	_, err = io.WriteString(file, fmt.Sprintf("%d\n", sum))
	return err
}