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: sorter.go
    path of file: ./repos/gomacro/base/dep
    
    the code of the file until where you have to start completion: /*
 * gomacro - A Go interpreter with Lisp-like macros
 *
 * Copyright (C) 2018-2019 Massimiliano Ghilardi
 *
 *     This Source Code Form is subject to the terms of the Mozilla Public
 *     License, v. 2.0. If a copy of the MPL was not distributed with this
 *     file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 *
 * sorter.go
 *
 *  Created on: May 03, 2018
 *      Author: Massimiliano Ghilardi
 */

package dep

import (
	"go/ast"
	"go/token"

	"github.com/cosmos72/gomacro/ast2"
)

func (s *Sorter) Lo
    
func (s *Sorter) popPackages() []*Decl {
	var list DeclList
	i, n := 0, len(s.queue)
loop:
	for ; i < n; i++ {
		node := s.queue[i]
		switch node := node.(type) {
		case nil:
			continue
		case *ast.GenDecl:
			if node != nil && node.Tok == token.PACKAGE {
				for _, spec := range node.Specs {
					list = append(list, NewDeclPackage(spec, &s.scope.Gensym))
				}
				continue
			}
		}
		// /*DELETEME*/ fmt.Printf("popPackages stopping at node: %v %T\n", node, node)
		break loop
	}
	if i > 0 {
		s.queue = s.queue[i:]
	}
	if len(list) == 0 {
		return nil
	}
	return list.SortByPos()
}