You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: stacks.go
    path of file: ./repos/k6/vendor/go.uber.org/goleak/internal/stack
    
    the code of the file until where you have to start completion: // Copyright (c) 2017-2023 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

    
func (p *stackParser) parseStack(line string) (Stack, error) {
	id, state, err := parseGoStackHeader(line)
	if err != nil {
		return Stack{}, fmt.Errorf("parse header: %w", err)
	}

	// Read the rest of the stack trace.
	var (
		firstFunction string
		fullStack     bytes.Buffer
	)
	funcs := make(map[string]struct{})
	for p.scan.Scan() {
		line := p.scan.Text()
		if strings.HasPrefix(line, "goroutine ") {
			// If we see the goroutine header,
			// it's the end of this stack.
			// Unscan so the next Scan sees the same line.
			p.scan.Unscan()
			break
		}

		fullStack.WriteString(line)
		fullStack.WriteByte('\n') // scanner trims the newline

		if len(line) == 0 {
			// Empty line usually marks the end of the stack
			// but we don't want to have to rely on that.
			// Just skip it.
			continue
		}

		funcName, creator, err := parseFuncName(line)
		if err != nil {
			return Stack{}, fmt.Errorf("parse function: %w", err)
		}
		if !creator {
			// A function is part of a goroutine's stack
			// only if it's not a "created by" function.
			//
			// The creator function is part of a different stack.
			// We don't care about it right now.
			funcs[funcName] = struct{}{}
			if firstFunction == "" {
				firstFunction = funcName
			}

		}

		// The function name followed by a line in the form:
		//
		//	<tab>example.com/path/to/package/file.go:123 +0x123
		//
		// We don't care about the position so we can skip this line.
		if p.scan.Scan() {
			// Be defensive:
			// Skip the line only if it starts with a tab.
			bs := p.scan.Bytes()
			if len(bs) > 0 && bs[0] == '\t' {
				fullStack.Write(bs)
				fullStack.WriteByte('\n')
			} else {
				// Put it back and let the next iteration handle it
				// if it doesn't start with a tab.
				p.scan.Unscan()
			}
		}

		if creator {
			// The "created by" line is the last line of the stack.
			// We can stop parsing now.
			//
			// Note that if tracebackancestors=N is set,
			// there may be more a traceback of the creator function
			// following the "created by" line,
			// but it should not be considered part of this stack.
			// e.g.,
			//
			// created by testing.(*T).Run in goroutine 1
			//         /usr/lib/go/src/testing/testing.go:1648 +0x3ad
			// [originating from goroutine 1]:
			// testing.(*T).Run(...)
			//         /usr/lib/go/src/testing/testing.go:1649 +0x3ad
			//
			break
		}
	}

	return Stack{
		id:            id,
		state:         state,
		firstFunction: firstFunction,
		allFunctions:  funcs,
		fullStack:     fullStack.String(),
	}, nil
}